Recoil icon indicating copy to clipboard operation
Recoil copied to clipboard

Effects getLoaded method is returning stale atom state

Open dquinn40 opened this issue 2 years ago • 1 comments

Versions React: 18.2.0 Recoil: 0.7.5 Node: v16.14.2

The getLoadable method passed to an Atom Effect returns stale state. We recently upgraded to Recoil version 0.7.5 from version 0.5.2 and it no longer works as expected. I have created a simple app with a test case that illustrates the bug.

The app has two components. A parent component thats responsible for setting a sport and a child component that shows a list of teams in that sport. The selected sport is held in one atom and the list of filtered teams is held in another. The list of filtered teams is loaded using an effect. That effect determines what sport has been selected by using the getLoadable method passed to it. In the test case, even though the selected sport state has clearly been set, the getLoadable method is returning undefined.

dquinn40 avatar Sep 07 '22 11:09 dquinn40

I missed this issue yesterday when I was looking through the issues. Could they be related?

dquinn40 avatar Sep 07 '22 13:09 dquinn40