polemius / recoil-persist

Package for recoil state manager to persist and rehydrate store
https://polemius.dev/recoil-persist/
MIT License
348 stars 40 forks source link

Reset atoms no longer remove from local storage #50

Open caviyacht opened 2 years ago

caviyacht commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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

polemius commented 2 years ago

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