-
Notifications
You must be signed in to change notification settings - Fork 558
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
RFC: useGlobalState #224
base: main
Are you sure you want to change the base?
RFC: useGlobalState #224
Conversation
Why not have the keys be |
I had a similar but a slightly different approach. Check my implementation of useSync(). Do you think that it is worth creating an RFC for? |
See react-use createGlobalState. |
@wmzy You'll still have to import the hook into different components in order to use it, which is not ideal. A subscription based one with a unique identifier (either a string or a symbol) will be way handier and will cause less headache when trying to remember which hook to import and where to import it from. |
Libraries like How would Example using
|
@bennoinbeta And why going for third party solutions if React already had this built-in? Given how crucial this is and how simple it is to implement, it makes sense to have it included in core. |
This is the global state implemented using batch updates. The usage is similar to useState, simpler than context, and the usage scenarios are different.
Here is my implementation and usage example.