Skip to content

how do you read data from a store outside of react? #122

Answered by lostpebble
jmchuster asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Jonathan,

If you really need to get a store's state outside of React- the recommended way is to use Store.getRawState() - which will return the actual state snapshot of that store at that time. Using hooks outside of React components will give you weird results, like maybe what you're seeing.

Also- I wouldn't recommend adding functions directly on their store class like you're doing here. Internally, the class recreates itself at some points (after server rendering and such) and it might lose those properties. Rather just create a separate object called ImageStoreActions or something that's external to the store, to hold those functions.

Hope that helps!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jmchuster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants