question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

atomWithProxy triggers infinite loop

See original GitHub issue

When 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:closed
  • Created 2 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
dai-shicommented, Aug 1, 2021

Would you update valtio v1.1.3 in devDependencies in #625 and if it passes the test?

1reaction
israelidannycommented, Aug 1, 2021

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 ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found