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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

produceWithPatches(draft => nothing) puts the nothing symbol in the patches #791

Closed
3 tasks done
dxinteractive opened this issue May 5, 2021 · 2 comments
Closed
3 tasks done

Comments

@dxinteractive
Copy link

dxinteractive commented May 5, 2021

馃悰 Bug Report

Link to repro

https://codesandbox.io/s/immer-sandbox-forked-7htbs?file=/src/index.ts

To Reproduce

var {produceWithPatches, nothing, enablePatches} = require("immer")
enablePatches(true);
let [newState,patches] = produceWithPatches({abc: 123}, draft => nothing);
// newState is undefined <- correct
patches[0].value === nothing <- incorrect?

Observed behavior

The immer nothing symbol can appear as the value in "replace" patches. Is this right? I thought the purpose of the nothing symbol was to simply give producers a way of differentiating between a mutating producer that implicitly returned undefined, and a returning producer that wants to output undefined as the next state. If that's true then perhaps the nothing symbol should not appear outside the producer itself.

Expected behavior

Patches that are produced setting state to nothing should have a value of undefined.

Environment

  • 9.0.2
  • I filed this report against the latest version of Immer
  • Occurs with setUseProxies(true)
  • Occurs with setUseProxies(false) (ES5 only)
@mweststrate
Copy link
Collaborator

Confirmed, reproduction: https://codesandbox.io/s/immer-sandbox-forked-fs9n5?file=/src/index.ts

@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2021

馃帀 This issue has been resolved in version 9.0.4 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants