Skip to content

How Can I call hooks in Atom Effect #2041

Answered by drarmstr
Gumichocopengin8 asked this question in Q&A
Discussion options

You must be logged in to vote

Hooks can only be called from the render functions of React components or other hooks. They should not be called from callbacks, effects, or otherwise outside of a component render. They cannot be conditionally called. useRecoilCallback() can be useful to create a hook which can call other hooks and define a callback which can get/set selectors/atoms. The recoil-sync library can also support a pattern which creates a store from a component that can use props or hooks.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Gumichocopengin8
Comment options

Answer selected by Gumichocopengin8
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