- 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
- 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
Yes, action creators knowing the state shape is generally an anti-pattern. It's fine if you normalize data from the server to some common shape and merge that into the state — but then you don't even need to react to different actions. Check out
real-world
example and itsentities
cache to get an idea of how to do that.It all depends on where the source of truth is. If data from server is source of truth, just admit it by having an
entities
reducer that merges any new info right from the action. If you have complex local (or optimistic) mutations, this is the point where actions would be thin, and most of the logic would be inside the reducers.