recoil-persist
recoil-persist copied to clipboard
Reset atoms no longer remove from local storage
It appears that Recoil 0.4.0 introduced a breaking change around how the DefaultValue
and effects work. The onSet
method no longer gets the DefaultValue
when reset, but instead an actual value. The logic to remove the key from local storage was dependent on this.
https://recoiljs.org/blog/2021/07/30/0.4.0-release#fixes-and-optimizations
Update to this. I mentioned on the Recoil repo that it appears to function correctly if you use a selector as the default value to an atom. I've switched to using this for now, but it seems like that might not stay as well.
@polemius , Recoil 0.5 was released with an enhancement to this area. isReset
can now be used to know if an atom was reset in an effect.
ref: https://github.com/facebookexperimental/Recoil/pull/1358
Thank you! New resetting atom logic was just released in 4.0.0.