recoil-persist
recoil-persist copied to clipboard
Reseting atom causes key to be empty instead of default value
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
}
I have released a new 2.3.0 version with your fix.
This is still not working in version 2.4.0
The new version 2.5.0 with fix just released.