Skip to content

Atom derived from async atom is stuck in suspense #3038

Closed Answered by dai-shi
amagana8 asked this question in Q&A
Discussion options

You must be logged in to vote

This causes infinite loop because it creates a new atom instance on every render.

  const person = useAtomValue(personAtom(id));

There are some approaches, one of which is atomFamily:

const personAtom = atomFamily((id: string) =>
  atom(async (get) => (await get(queryAtom))[id]));

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by amagana8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants