This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
-
A similar question was asked previosly (#1193), but for some reason a selector was used in the example, so it's still not clear which one is preferable or it's just a matter of taste. I don't think there's any difference, but it would be nice to know for sure. const setSomething = useSetRecoilState(myAtom);
const handleOnClick = useCallback((event) => {
// ...
setSomething('something')
}, [setSomething]) vs const handleOnClick = useRecoilCallback(({ set }) => (event) => {
// ...
set(myAtom, 'something')
}, []) |
Beta Was this translation helpful? Give feedback.
Answered by
drarmstr
Oct 4, 2022
Replies: 1 comment 1 reply
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Dattaya
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
useSetRecoilState()
is more efficient, butuseRecoilCallback()
can handle more complex situations.