If the dependency of the atom being get by useAtomCallBack(write-only atom) is changed, that atom will be read. #2789
Unanswered
hi-ogasawara
asked this question in
Bug report
Replies: 1 comment 2 replies
-
jotai/src/react/utils/useAtomCallback.ts Line 16 in 62c4892 useAtomCallback shouldn't subscribe to an atom. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Bug Description
Atoms not used in components are read
I thought it would not read for the following reasons, but it does
Even though read-only atom (fetchAtom) is used only with useAtomCallBack When “userConfigTime” is used in a component, fetchAtom is read.
*The same event occurs with write-only atom instead of useAtomCallBack To confirm, uncomment the write-only pattern.
NOTE
If you change a dependency without ever updating it, fetchAtom is not read.
*The same event occurs with write-only atom instead of useAtomCallBack To confirm, uncomment the write-only pattern.
Instead of userConfigTime in fetchAtom Get (uncomment) wrapUserConfigTime. If the dependency is updated after this, wrapUserConfigTime is read instead of fetchAtom.
*The same event occurs with write-only atom instead of useAtomCallBack To confirm, uncomment the write-only pattern.
Inference from the above
It is likely that atom has been read in the following conditions.
(userConfigTime in fetchAtom in useTestAPI is used by the component.)
(In this case, dependencies are only tracked up to the first level.)
Reproduction Link
https://github.com/hi-ogasawara/AtomCallBackTest.git
Beta Was this translation helpful? Give feedback.
All reactions