When should you use action creator and when reducer?
Action creator
- you need to have side effects
- you need to read from store to decide what to do
- you need to dispatch more than one action
- action produced by action creator needs to contain all the data reducer can need to shape the components state
Reducer
- should not have any side effects
- should not read global application state
- should not manipulate data structures passed with the action, it should only pick the right data and merge it into state
This comment has been minimized.
There was one case where our reducer also managed the Cookie. At login success the cookies with the auth toke was set. At logout it was removed. Would you move this side-effect also to the action creator?