getState for non-redux version
See original GitHub issueThere is no getState for createGlobalState (the one you use without redux).
So its not possible to get the state inside a non-react functional component without write this hack.
var state;
setGlobalState('login', v => {
state = v;
return v;
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:17 (11 by maintainers)
Top Results From Across the Web
How can I get an immutable version of an object from store ...
I'm using react-redux for a project I'm working on. I noticed that when I grab an object from my store and edit it,...
Read more >Build Yourself a Redux - The Zapier Engineering Blog
Redux is a simple library that helps you manage the state of your JavaScript app. Despite that simplicity, it's easy to fall down...
Read more >Redux-Observable will solve your state problems. - ITNEXT
To do so, you're almost always going to be calling into their non-Redux ... Redux-Observable, prior to version 1, did not handle immediate...
Read more >npr/redux-external-dispatchers - GitHub
A Redux store enhancer to let non-Redux pieces of your application dispatch actions into Redux without also having access to Redux state.
Read more >redux-selector-subscribe - npm
Latest version: 1.0.0, last published: 5 years ago. ... still use cases for notifying your non-Redux code about an update to Redux state....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Anyway, let’s merge #18.
In short, I would only export keyed API. If someone really need a whole object, one can do the following:
This is a bit of extra work, and one should use
getGlobalState(key)
whenever possible.What’s important here is that the fact that this library uses
observedBits
is an implementation detail, and React may drop this API at any time. If it’s simply dropped, I would change the implementation to use multiple contexts and thegetWholeGlobalState
might be implemented just like the above. I believe that exportinggetWholeGlobalState
encourages the misuse of it.