atomWithDefault should accept an update function that returns RESET like atomWithReset #3136
Unanswered
scamden
asked this question in
Bug report
Replies: 1 comment 2 replies
-
It's not about the typing, but about the capability of atomWithDefault, right? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Description
atomWithReset accepts set updates as a function that potentially returns RESET based on previous value and the types reflect this. atomWithDefault doesn't. It only accepts RESET as literal not as the result of the update function. This makes the types of the two atoms incompatible. Would be great to have atomWithDefault do the same behavior.
Reproduction Link
https://www.typescriptlang.org/play/?#code/MYewdgzgLgBASgUQMoICowLwyQTwLYBGIANgBQDkATgKYTVTkCUA3AFBQ4AO1MAhpQHMImGAG1SpRpgB8MMAFdC1SjEYAfOYoLKYGjtxAAzeMjQBddlx406UAIKDhWcZJkxSCpZT1WjJlKiMUhqe2io+BsaIARashvJgwFAAluAw4NSkAHQ5-EIwAFx8jlIA3qysAL4V8YkpaVAA7iDZuY5FNvQOQmUV1aygkLC8BfrUfk0gIhnMQA
Beta Was this translation helpful? Give feedback.
All reactions