javascript - What are differences between redux, react-redux, redux-thunk? -
i using react + flux. our team planning move flux redux. redux confusing me coming flux world. in flux control flow is simple components -> actions -> store , store updates components. simple , clear.
but in redux confusing. there no store here, yes there examples without using store. went through several tutorials, seems has own style of implementation. using containers , not. (i don't know containers concept , not able understand mapstatetoprops, mapdispatchtoprops does).
- can explain how control flow happens in redux ?
- what roles of components/containers/actions/action creators/store in redux ?
- difference between redux/react-redux/redux-thunk/any others ??
- it helpful if can post links simple , precise redux tutorials.
- can explain how control flow happens in redux ? redux has (always) single store.
whenever want replace state in store, dispatch action.
the action caught 1 or more reducers.
the reducer/s create new state combines old state, , dispatched action.
the store subscribers notified there new state.
- what roles of components/containers/actions/action creators/store in redux ?
store - holds state, , when new action arrives runs dispatch -> middleware -> reducers pipeline, , notifies subscribers when state replaced new one.
components - dumb view parts not aware of state directly. know presentational components.
containers - pieces of view aware of state using react-redux. known smart components, , higher order components
note containers / smart components vs. dumb components way structure app.
actions - same flux - command pattern type , payload.
action creators - dry way of creating actions (not strictly necessary)
- difference between redux/react-redux/redux-thunk/any others ?
redux - flux flow single store, can used in whatever enviroment including vanilla js, react, angular 1/2, etc...
react-redux - bindings between redux , react, creates containers (smart components) listen store's state changes, prepare props , rerender presentational (dumb) components.
redux-thunk - middleware allows write action creators return function instead of action. thunk can used delay dispatch of action, or dispatch if condition met. used async calls api, dispatch action on success / failure.
- it helpful if can post links simple , precise redux tutorials.
Comments
Post a Comment