A brief summary of Redux

Time:2021-1-16

Redux

https://redux.js.org/
https://cn.redux.js.org/

store.getState()

https://redux.js.org/api-refe…

This function returns to get the lateststateIt will not be triggered by the outside world.

store.subscribe(listener)

https://redux.js.org/api-refe…

This function returns a functionunsubscribe

After this function is executed, as long asstoreOfstateAny change, functionlistenerIt will be executed. Until the functionunsubscribeIs called.

At present, there is no official monitoringstatePart of the way to change.

store.dispatch(action)

https://redux.js.org/api-refe…

After this function is executed, thestateByactionMembers mentioned will bereplace

This function returnsaction

react-redux

https://github.com/reduxjs/re…
https://segmentfault.com/a/11…

// react-redux

connect([mapStateToProps], [mapDispatchToProps], [mergeProps], [options])

mapStateToProps(state)

mapDispatchToProps(dispatch, ownProps)

functionmapStateToProps(state, ownProps)

This function canstate(or its members) are bound to the component as props.ownPropsIs the props of the component itself.

Once the props change, the component will re render.

functionmapDispatchToProps(state, ownProps)

This function providesdispatchSo that components can be created for changestateThe props (function) of.ownPropsIs the props of the component itself.

This function is related tostore.dispatchThe only advantage is that if the component definition is not in the entry file (such asindex.js)This method can be avoidedimportGlobal in the entry filestore. So, this function doesn’t really make much sense.

Recommended Today

Oracle automatic collection task statistics, SQL tuning

–View auto collection task status SELECT CLIENT_NAME,STATUS FROM DBA_AUTOTASK_CLIENT; SELECT CLIENT_NAME, STATUS FROM DBA_AUTOTASK_CLIENT WHERE CLIENT_NAME = ‘auto optimizer stats collection’; –Turn off auto optimizer stats collection BEGIN DBMS_AUTO_TASK_ADMIN.DISABLE(CLIENT_NAME => ‘auto optimizer stats collection’, OPERATION => NULL, WINDOW_NAME => NULL); END; / –Shut down SQL optimizer SQL Tuning Advisor (STA) BEGIN DBMS_AUTO_TASK_ADMIN.DISABLE(CLIENT_NAME => ‘sql tuning […]