Skip to content

If the dependency of the atom being get by useAtomCallBack(write-only atom) is changed, that atom will be read. #2789

Discussion options

You must be logged in to vote

Your understanding of the behavior of useAtomCallback and the internal workings of Jotai is largely correct, but the distinction you’ve noted between atom.read and atom.write deserves some clarification, particularly regarding dependency tracking within the context of write operations.

Here’s a more detailed explanation:


Key Observations

  1. atom.read Behavior:

    • The get function in atom.read is designed to track dependencies. When you call get(atom) within an atom.read function, Jotai automatically adds the accessed atom to the dependency list of the current atom. This enables reactivity: changes to any of the dependencies trigger a re-evaluation of the atom.
  2. atom.write Behavior:

    • The get

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
3 replies
@hi-ogasawara
Comment options

@dai-shi
Comment options

@dai-shi
Comment options

Comment options

You must be logged in to vote
3 replies
@hi-ogasawara
Comment options

@dmaskasky
Comment options

@hi-ogasawara
Comment options

Answer selected by dmaskasky
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
3 participants