Why use Redux middleware?
Consider the Redux Async Data Flow Diagram. Describe the flow in your own words.
store.dispatch(action)
. The action is then passed to the middleware, which can either pass it on to the next middleware, or pass it to the reducers. The reducers then update the state, and the state is passed back to the React component.How are we accomodating async in our Redux app?
redux-thunk
middleware. This middleware allows us to write action creators that return a function instead of an action. The thunk can be used to delay the dispatch of an action, or to dispatch only if a certain condition is met. The inner function receives the store methods dispatch
and getState
as parameters.Why would you need redux-thunk
middleware?
Redux Thunk middleware allows you to write action creators that return a function instead of an action.
Describe how any return value from the inner thunk function will be made available.
dispatch
and getState
as parameters. The inner function can then dispatch actions and read the current state of the Redux store.What are your learning goals after reading and reviewing the class README?