Redux Thunk

redux-thunk

As redux middleware to run the code after action is dispatched, before it reaches to the reducer.

Middleware allows to write action creator return function instead of action, such function can delay the dispatch of action or dispatch action under certain condition.

  • innerfunction recieve dispatch() and getState() store methods

To set up middleware pipeline

import { applyMiddleware } from 'redux';
  • pass into createStore() as StoreEnhancer to trace application
    applyMiddleware(thunk,logger)

Redux-thunk is userful for some complex synchronous logic

  • Multiple dispatches
  • Conditional dispatches
  • Simple Async logic
    • for complex async logic, redux saga is an option, which function like ongoing ‘background thread’

react-redux-form

It is different from local form as it can map into store, so that state of form will be persist in the store, which means when navigation to other components, filled information will keep in filled.

  • data persistence
  • own form validation
# redux

Commentaires

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×