State Management
Thunk
A thunk is a function you dispatch instead of an action object. The thunk runs with (dispatch, getState) so it can perform async work and then dispatch actions.
How it works
- If
dispatchreceives a function, the thunk middleware runs it - The reducer never sees the function, only the actions it dispatches
Why it matters
- Keeps reducers pure
- Enables async and multi-step flows