How Can I call hooks in Atom Effect #2041
-
I wanna call |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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. |
Beta Was this translation helpful? Give feedback.
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. Therecoil-sync
library can also support a pattern which creates a store from a component that can use props or hooks.