-
-
Notifications
You must be signed in to change notification settings - Fork 87
getGlobal #35
Comments
It isn't currently publicly accessible, or if it is it's not by design. It follows the law of encapsulation. All exposed states are copies of the state such that direct access to mutate isn't possible. What is your use case for copying state outside of React, and maybe it can be worked around, or maybe it will be convincing to publicly expose the global state? |
I just mean to use it like store.setState({count:1}) outside of react component. Like with easy-peasy |
I could see a use for this.
I often maintain ‘lib’ and ‘helper’ functions that are called by buttons or ui interactions but do some fancier stuff, being able to manipulate the global state from those files without passing in the global state function could be nice.
Justin
… On Jan 11, 2019, at 12:54 PM, Pavel Ravits ***@***.***> wrote:
I just mean to use it like store.setState({count:1}) outside of react component. Like with easy-peasy
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#35 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AIl7xbG5SeNlOeN8YPtYhrNwf3SrR4yeks5vCMG1gaJpZM4Z69wp>.
|
Setting the state can, yes. It's not recommended over import { setGlobal } from 'reactn'; Let me know if you have any further questions or if this issue can sufficiently be closed. |
Hi, As I am working on a library function it will be glad to access the store directly (now I am passing this.global from reactn components). I am now trying to import setGlobal directly, but it will be great to have a way to access "this.global" outside of a reactn component... as workaround I also found that I can make a class that extends react(n).component but I like more regular functions Thanks! *Edit: I'm using react 16.5.0 so no useGlobal hooks :-( |
Not currently, but I'm not opposed. Would something like |
that would be great! I switched one project to Reactn and it’s incredible how easy it is to manage global state.... setGlobal() works perfectly inside library functions, while creating a class component Thank you very much for your great work! |
I'll try to have an iteration of this soon for single-store support only. |
I'd just like to state that I have this existing in my local repository, but it's pretty important to me that I get unit tests completed for the project as a whole before cutting a new version, so I do not have an ETA on release. I may do an alpha release if the unit tests delay this too much. |
I am currently migrating a medium size (25 screens) Expo React Native project from Unstated to Reactn, if you release the alpha version with GetGlobal I can help with testing it out :-) |
I have released I added some unit tests and manual app testing to try to insure there were no breaking changes, but this version included a major change to some internal workings. I would love some community feedback on if any errors are discovered. Thank you for your patience. I'm sorry about the long delay. I have been unable to contribute for the past month, but I'm hoping to begin knocking out a lot of ReactN's open issues now. |
Thank you for the quick release! |
No description provided.
The text was updated successfully, but these errors were encountered: