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

Maybe update docs #1123

Open
olegdunkan opened this issue May 16, 2024 · 0 comments
Open

Maybe update docs #1123

olegdunkan opened this issue May 16, 2024 · 0 comments
Labels

Comments

@olegdunkan
Copy link

olegdunkan commented May 16, 2024

🙋‍♂ Question


const a = { id: 1 };
const b = { id: 2, children: [a] };

const objs = { 1: a, 2: b };

const fn = produce((draft) => {
  draft[2].children[0].x = 1;
});

const r = fn(objs);

console.log(r[1]); // {id:1}
console.log(r[2].children[0]); //{id:1, x:1}


In two places of objs we have two pointers to the same object a but when we change it in one place we treat it like two different objects.

I expected that to be

console.log(r[1]); // {id:1, x:1}
console.log(r[2].children[0]); //{id:1, x:1}

I didn't find anything about that in docs.

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

No branches or pull requests

1 participant