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.

Setting atom from an effect concurrently with another update loses the value

See original GitHub issue

Potentially, 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

  1. Click “Navigate!”. Observe that “State A” value is empty and “State B” is “hello”.
  2. Now reload page in the embedded browser with ?delay added to the URL.
  3. Click “Navigate!”. Observe that “State A” value is now correct (“from effect”) and “State B” is “hello”.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
drarmstrcommented, Dec 1, 2020

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…

0reactions
drarmstrcommented, May 6, 2021

@mdlavin - Thank you very much for the test case! Yes, I suspect this test is unrelated to the original issue here.

Read more comments on GitHub >

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

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