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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base state is not reconciled if read from draft and reassigned #659

Comments

@davidye
Copy link

davidye commented Aug 27, 2020

🐛 Bug Report

const {produce} = require("immer");

const bar = {};
const foo = {bar};

console.log(
  produce(foo, (draft) => {
    // comment next line out and it works as expected
    draft.bar;
    draft.bar = bar;
  }) === foo
);

Accessing draft.bar and then setting draft.bar to the same value breaks immutability. This appears to be a regression starting from version 7.0.0 onwards. Works as expected in 6.

Link to repro

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

Environment

We only accept bug reports against the latest Immer version.

  • Immer version: 7.0.0 onwards
@mweststrate mweststrate added the bug label Sep 2, 2020
@mweststrate mweststrate changed the title Immutability breaks when accessing draft (regression in v7) Base state is not reconciled if read from draft Sep 2, 2020
@mweststrate mweststrate changed the title Base state is not reconciled if read from draft Base state is not reconciled if read from draft and reassigned Sep 2, 2020
@aleclarson
Copy link
Member

🎉 This issue has been resolved in version 7.0.13 🎉

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