atomWithProxy triggers infinite loop
See original GitHub issueWhen using atomWithProxy
merely referencing any value from the state will cause an infinite loop. I created a minimal reproduction of the bug:
https://codesandbox.io/s/jotaivaltio-infinite-loop-yphdz?file=/src/App.js
It has a proxy atom and it uses it like so:
const [atomState] = useAtom(proxyAtom);
If you just print out something like JSON.stringify(atomState)
everything is great, but the moment you do a simple change to JSON.stringify(atomState.someNestedKey)
everything freezes in an infinite loop (even though the key exists and prints out successfully without being referenced directly.
Issue Analytics
- State:
- Created 2 years ago
- Comments:16 (16 by maintainers)
Top Results From Across the Web
Infinite loop when Suspense contains a Provider with ... - GitHub
I've tried debugging this issue because I thought it was weird that it doesn't work only with initialValues . I've found out that...
Read more >David K. on Twitter: "@dai_shi I just tried but it goes into an ...
I just tried but it goes into an infinite loop if you do: useAtom(createSomeAtom(...)) Because it'll always be a different ref.
Read more >How to Solve the Infinite Loop of React.useEffect()
The idea is that updating a reference doesn't trigger re-rendering of the component. Here's a possible implementation: jsx. import { useState, ...
Read more >3 ways to cause an infinite loop in React - Alex Sidorenko
React limits the number of renders to prevent an infinite loop. Here are 3 potential causes of the infinite loop in React.
Read more >setState array cause infinite loop - reactjs - Stack Overflow
I have lists of arrays created from sampling size. When I setState the array with the entire new array. I got an error...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Would you update valtio v1.1.3 in devDependencies in #625 and if it passes the test?
I think that this issue can be closed (infinite refresh bug fixed) and the types can be tracked in the PR, what do you think @dai-shi ?