Using Promise.all
inside component causes indefinite suspend
#1782
-
According to the migration docs |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Yeah, creating a new atom in render can cause infinite loop. You want to define the atom outside. Here's the fix: Granted, |
Beta Was this translation helpful? Give feedback.
Yeah, creating a new atom in render can cause infinite loop.
You want to define the atom outside. Here's the fix:
https://codesandbox.io/s/jotai-promise-all-indefinite-suspend-forked-80yo88?file=/src/Example.js
Granted,
waitForAll
as well as other utils had a special caching mechanism, which Promise.all doesn't have. Currently, there are no easy solution other than defining an atom outside component. For more complex use cases, we may need some kind of memoization. Let us know if you are in such situation.