Great work! And some comments/tips
See original GitHub issueI really like how almost identical it is to redux, and how it enables me early access to some of the things that might trickle down into react-redux. I don’t like however that initial state is required.
I use typesafe-actions for mostly everything. And I use initial state in my reducers and have never depended on providing initial state on the top level where I combine the reducers. I mean, how silly is that? Therefore I have to do the following to be compliant with this library, and its really not a big deal:
const initialState = reducers(undefined, { type: undefined });
export const { GlobalStateProvider, dispatch, useGlobalState } = createStore(
reducers,
initialState,
enhancers
);
Isn’t there a possibility that this library could do this automatically when it doesn’t receive initial state?
otherwise, I am going to do some tests now where I confirm the fact that needs to just work: sibling components that uses useGlobalState should not be affected by unrelated updates to the global state. I am sure that it works, but I haven’t got the time to make this test yet. By opening react devtools and highlighting updates, this is very easy to check, but I need to just hack up some components.
Issue Analytics
- State:
- Created 5 years ago
- Comments:31 (31 by maintainers)
Top GitHub Comments
@dai-shi i will update the wiki if i am allowed to 😃 (i am. Great 😉)
Ooh … and i have confirmed btw that the library does what its supposed to 😃 made two sibling components with different substate subscriptions. and they do logically not cause the other component to update when dispatching an action that should only affect the one. just needed to test it, since its a basic assumption/requirement.