atomWithImmer setting to undefined value #3096
Replies: 1 comment
-
Realised after posting that this should perhaps be in jotai-immer. The issue is there where the calue isn't tested for undefined. With immer for undefined, produce has to return immer.nothing (https://immerjs.github.io/immer/return/#:~:text=Producing%20undefined%20using%20nothing%20%E2%80%8B&text=So%2C%20by%20default%2C%20Immer%20will,tried%20to%20modify%20the%20draft.&text=N.B.%20Note%20that%20this%20problem,t%20suffer%20from%20this%20issue.) Tried to transfer discussion, but github won't allow as repo owned by different user. I'll close and re-open there |
Beta Was this translation helpful? Give feedback.
0 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
When configuring an atomWithImmer that accepts undefined values, setting to undefined is a NOOP and doesn't work as expected.
In the above example, toggling that state between undefined and number does not work as I would expect. You can set to a number, but not set back to undefined.
The nullable state works as expected.
Is this expected behaviour?
Reproduction Link
https://react-starter-typescript-61zk5bdn.stackblitz.io
Beta Was this translation helpful? Give feedback.
All reactions