Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reseting atom causes key to be empty instead of default value #26

Open
toddmcbrearty opened this issue Feb 16, 2021 · 3 comments · May be fixed by #36
Open

Reseting atom causes key to be empty instead of default value #26

toddmcbrearty opened this issue Feb 16, 2021 · 3 comments · May be fixed by #36

Comments

@toddmcbrearty
Copy link
Contributor

When you reset the atom it becomes an empty state saved in storage. According to the docs https://recoiljs.org/docs/guides/atom-effects/#asynchronous-storage-persistence the key should be removed when it's a default value (at least for now)

the fix is to simply add this to onSet

if (newValue instanceof DefaultValue) {
      if(state.hasOwnProperty(node.key)) delete state[node.key];
} else {
     state[node.key] = newValue
}
@polemius
Copy link
Owner

I have released a new 2.3.0 version with your fix.

@ramiel
Copy link

ramiel commented Mar 13, 2021

This is still not working in version 2.4.0

@polemius
Copy link
Owner

The new version 2.5.0 with fix just released.

bartvanremortele added a commit to bartvanremortele/recoil-persist that referenced this issue Apr 16, 2021
bartvanremortele added a commit to bartvanremortele/recoil-persist that referenced this issue Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants