recoil-persist icon indicating copy to clipboard operation
recoil-persist copied to clipboard

Reset atoms no longer remove from local storage

Open caviyacht opened this issue 2 years ago • 3 comments

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

caviyacht avatar Oct 25 '21 20:10 caviyacht

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.

caviyacht avatar Oct 29 '21 17:10 caviyacht

@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

caviyacht avatar Nov 05 '21 20:11 caviyacht

Thank you! New resetting atom logic was just released in 4.0.0.

polemius avatar Nov 07 '21 05:11 polemius