How to share atom between Provider and custom hook #1327
Replies: 2 comments
-
Provide <Provider scope="foo">
...
</Provider>
useAtom(anAtom, "foo") // will use the closest Provider with "foo" scope in the component tree. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a library that wraps itself in a Provider:
<Provider> /* my library code */ </Provider>
.But I have a custom hook, e.g.,
useMyLibraryHook
, associated with this library that needs to access the atoms under<Provider />
.If I don't use a
<Provider />
, the atoms are "global" and are accessible. But under a<Provider />
, I can't find out how to access them.How can I access the atoms within the custom hook?
Thank you very much!
Beta Was this translation helpful? Give feedback.
All reactions