Skip to content

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

Description

@davidye

馃悰 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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions