Closed jennmueng closed 2 years ago
Hi, I had some time and I tried to reproduce this, without much luck. To answer your concern I would appreciate if you could help me replicate the unexpected behavior, this is what I tried: CodeSandbox
i'm encountering this too....
I'm often encountering issues where the recoil state is not updated synchronously after a setRecoil
as well.
Wish I could provide a reproducible example but have yet to have the time to look into creating one. The app is a pretty large closed source React Native application. I wonder if either the fact that the component tree is gigantic or the library is running on React Native has any effect on this issue.
@burgalon @luisanton-io I found a fix and pushed it to #22, sorry that I'm still unable to provide a reproducible but this fix was what worked for our app.
Thanks @jennmueng ! Published in 0.3.16. Closing for now.
I have a component that calls an async function inside a
useEffect
which has a dependency on a string value inside a Recoil atom state. Inside theuseEffect
the valuelocationName
is the latest value, while in the async function call that immediately callsgetRecoil
returns the old value (that defaults to the empty string""
). CallinggetRecoil
again inside asetTimeout
returns the new value however.The logs:
For now I'll be passing through the
locationName
as an argument to thegetTopPicks
function but does anyone have any insight on why this bug happens?