Setting atom from an effect concurrently with another update loses the value
See original GitHub issuePotentially, similar to #728.
Setting atom value inside an effect (via setSelf
) while another update is happening loses the state change. Delaying setSelf
via window.requestAnimationFrame
solves the issue.
Here is the reproduction case I have: https://codesandbox.io/s/xenodochial-firefly-wny9s?file=/src/App.js
- Click “Navigate!”. Observe that “State A” value is empty and “State B” is “hello”.
- Now reload page in the embedded browser with
?delay
added to the URL. - Click “Navigate!”. Observe that “State A” value is now correct (“from effect”) and “State B” is “hello”.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Can I change other pieces of state in a Recoil Atom Effect
I am using Recoil to manage state in a React application. I am using Atom Effects to back up recoil values with an...
Read more >Momentum Conservation Principle - The Physics Classroom
Two colliding object experience equal-strength forces that endure for equal-length times and result ini equal amounts of impulse and momentum change.
Read more >Class: Concurrent::TVar — Concurrent Ruby
The atomically method allows you to modify a set of TVar objects with the guarantee that all of the updates are collectively atomic...
Read more >Molecular Structure & Bonding - MSU chemistry
In most cases the focus of configuration is a carbon atom so the lines ... and also illustrate the importance of including non-bonding...
Read more >ACID Explained: Atomic, Consistent, Isolated & Durable
Together, ACID is a set of guiding principles that ensure database ... resources on the assumption that transactions will impact other ones.
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 FreeTop 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
Top GitHub Comments
Found the issue, thanks for the great repro @idubrov! I have a fix in the works, though may be delayed through reviews due to holidays…
@mdlavin - Thank you very much for the test case! Yes, I suspect this test is unrelated to the original issue here.