Pre-req:
Install thunks
Get organized - Create a
thunks.js
or a folder./thunks/
and the appropriate file names to group the related thunks.Import
action-creators
from the appropriate file(s) into your thunk file.Write your thunk(s).
Create a new
reducer
or update otherreducers
as appropriate and import any neededactions
.
4.1. If creating a newreducer
,import
it to store.js and add thereducer
to your reducers object.In the component needing the
thunk
, import thethunk
, add it to the appropriateprops
,mapState
, andmapProps
, and place thethunk
function 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)