Skip to content

I need help to share recoil root to other component and a way to get and set state outside of component #1839

Answered by drarmstr
Innovdata-damien asked this question in Q&A
Discussion options

You must be logged in to vote

Recoil state is coupled with the particular version of state being rendered for the host <RecoilRoot> store, and isn't "global" per-se. That said, from a component in that React component tree you can use something like useRecoilCallback() to create accessors and setters for reading and updating Recoil state from outside of rendering functions. There are also third-party libraries like recoil-nexus, I think, that provide this pattern.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Innovdata-damien
Comment options

You must be logged in to vote
0 replies
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