这是indexloc提供的服务,不要输入任何密码
Skip to content

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

@toddmcbrearty

Description

@toddmcbrearty

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions