Redux Thunk
https://codepen.io/stowball/post/a-dummy-s-guide-to-redux-and-thunk-in-react
npm install --save redux-thunk
To handle async action creators.
Action Creator must return a function instead of action, this function will be called automatically with ‘dispatch’.
step by step
- Action creator called
- Action creator returns a function
- Redux thunk sees that we returned a funcion and calls it with dispatch
- Wait for the async request to complete
- Request conpleted, .then function of the async request runs.
- Redux thunk now dispatch our action