Open markerikson opened 5 years ago
Debating the naming a bit.
I've been labeling this section as "Real World Usage". RTK and React-Redux currently have sections called "Using React-Redux" / "Using Redux Toolkit". Currently, the "Recipes" section is kinda along the lines of what we want this to eventually be.
Just put up a poll asking for preferences on naming:
I wrote a post about ways to semi-predictably use randomness "safely" a couple years ago:
https://blog.isquaredsoftware.com/2018/01/marks-dev-links-001/#experiments-with-randomness-in-redux
and this post appears to be covering something similar:
https://spin.atomicobject.com/2020/01/21/redux-restorable-randomness
Discussion on cross-importing slices and dealing with circular references:
More waffling over naming: https://twitter.com/acemarke/status/1355992742522880000
Final results of that poll:
Despite it getting fewer votes, I think I'm basically set on "Using Redux" at this point.
We ought to rework "Configuring Your Store" some:
configureStore
is first, and maybe show an example of writing that wrapper around configureStore
for your preloaded state or similar (because that probably will pop up when you start writing tests)Random bit I wrote on Reddit years ago and always meant to include - some conceptual thoughts on "ways to model a problem" / "where does business logic go?":
As a specific example, let's say that you have a todo list (of course) that can only hold 5 todos max. You could:
- Always dispatch
"TODO_ADDED"
, and let the reducer ignore the action and do nothing if there's already 5 entries- Get the
state.todos
array as a prop in a component, check the size when they click "add", and not dispatch if there's already 5- Dispatch a thunk, call
getState()
, check the size ofstate.todos
, and not dispatch if there's already 5- Use a selector, determine if the size is 5, and disable the input field and "Add" button if that's the case
Personally, I'd go for some combination of 1 and 4. Prevent the user from actually doing invalid operations, and also have logic that prevents invalid states. But, 2 and 3 are potential ways to approach this as well.
https://www.reddit.com/r/reactjs/comments/dfvxke/is_redux_a_musthave/
Should link to https://calendar.perfplanet.com/2023/fastest-way-passing-state-javascript-revisited/ on the SSR page as a way to improve the perf of parsing JSON for preloaded state .
This is a tracking issue to cover all work related to creating the new
"Real World Usage""Using Redux" section.Original plan was to call it "Real World Usage", but after thinking it over further, I'm inclined to go with a category name of "Using Redux" to match the React-Redux and Redux Toolkit docs, with a category base URL of
/usage/
. (I see that I did do a Twitter poll almost a year ago, and "Real World Usage" won 60% to 18%, so I'm willing to discuss this further if anyone has particularly strong feelings about it.)Tasks
initModule(store)
function; broadcast store instance via event emitter; have modules provide middleware, etc)