Open markerikson opened 5 years ago
Would love to work on these also. But I feel these sections are more subjective than others so maybe will work on them later. Putting up a few resource links first
Totally can't forget @modernserf 's great post on What's So Great about Redux?.
A very good summary of the "business logic" approach:
https://twitter.com/FwardPhoenix/status/952972062058074112
"Can it be done with just dispatch arguments?" -> action creator. "Can it be done with previous state and action?" -> reducer "Can it be done from just state?" -> probably a component.
So "where does the business logic lives" -> everywhere.
Thoughts on teaching the "multiple reducers responding" pattern:
https://twitter.com/dai_shi/status/1184230104613810177
When I teach Redux, I find many beginners misunderstand that pattern. They are surprised when I tell that pattern is possible and even recommended. One of the reasons why this happens, I think, is combineReducers. It's in core and almost all examples use it
More bookmarks that could be useful:
"Modeling actions as events":
When we say "model actions as events", it implies a few different things:
- Naming: "somethingHappened", vs "setThing"
- Mindset: it's not "setters at a distance", it's "broadcast this info, any code that cares can do something with that info"
- Code layout: having more logic in a reducer, vs always calculating the entire state first -> sticking it in the action -> doing
return action.payload
orstate.someValue = action.payload
- Handling logic: it's fine for many reducers to update themselves independently in response
None of that goes away with RTK - it's more about a mental model than specific syntax.
These aren't absolutes, and in some ways it's a hard mindset shift to grasp. And, tbh, most Redux actions will only ever be handled by one slice reducer in practice. But, I've seen folks writing separate
setFieldX
,setFieldY
actions for every individual field in some slice, and that's definitely not the right mental approach.
This is a tracking issue for all work related to creating a new "Understanding Redux" section
Goal
Pasting from my original writeup in #3313 :
Tasks