I’m using React, Suspense, and Jotai.
I have a list of items where by, when one item is clicked, a modal pops up and based on the item’s id
, it makes an api call for detailed information about the item.
Based on https://jotai.org/docs/core/atom#note-about-creating-an-atom-in-render-function, memoizing the creation of the atom prevents infinite loops with useAtom
.
However, I’m still getting infinite request loops and stays stuck in the loading state.
Here’s a code sandbox replicating this issue: https://codesandbox.io/p/sandbox/jotai-x27mnl?file=%2Fsrc%2FItem.tsx%3A36%2C17