Pre-req:
Install thunks
Get organized - Create a
thunks.jsor a folder./thunks/and the appropriate file names to group the related thunks.Import
action-creatorsfrom the appropriate file(s) into your thunk file.Write your thunk(s).
Create a new
reduceror update otherreducersas appropriate and import any neededactions.
4.1. If creating a newreducer,importit to store.js and add thereducerto your reducers object.In the component needing the
thunk, import thethunk, add it to the appropriateprops,mapState, andmapProps, and place thethunkfunction were needed in the component.
Resources & References
Redux-Thunk Official
What Are Thunks? <-the best article on Thunks and how they work
Top comments (0)