Any drawback of using a custom hook for useAtom? #2718
-
Hi, I was wondering if there was any performance drawback of using a custom hook to encapsulate a call to useAtom? Here's what the custom hook would look like:
Then some components would only read from the atom: While others would write to it: Could that potentially mean that when a component only picks up |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Creating custom hooks is totally fine. For the performance, using |
Beta Was this translation helpful? Give feedback.
Creating custom hooks is totally fine.
For the performance, using
useSetAtom
is better.const { setInfo } = useInfo()
can cause extra rerenders.