Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find way to use top level component for all state #5

Open
lastmjs opened this issue Feb 7, 2020 · 0 comments
Open

Find way to use top level component for all state #5

lastmjs opened this issue Feb 7, 2020 · 0 comments

Comments

@lastmjs
Copy link
Owner

lastmjs commented Feb 7, 2020

It would be really nice to allow the top level component to hold all state, and pass state down to each component through props. This would make each child component in the tree more modular, without a dependency on a global Redux store. The big problem I see is making updates to the global store from within child components. There are a couple ways I can see to do it. One way is to raise an event when the global store needs to change. The top level component can register listeners for those events and then dispatch onto its store. The event handling will be asynchronous though, which might have drawbacks. It gets rid of the possibility of updating global state synchronously, and you have no way of awaiting the state change as far as I can tell.

Another way is to export the top level or pass it down through the props. But then that kind of defeats the while purpose of lossely-coupling the components and the global store. We've just added the dependency back.

If we can figure out how to await the global store change, that might work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant