immerjs / immerjs/immer

Maybe update docs

Open
#1,123 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
JavaScript
Stars
29k
Forks
881
PR merge metrics
No merged PRs in 30d

Description

🙋‍♂ 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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No documentation file or test is named. Start by reproducing the supplied JavaScript example with Immer's produce entry point, then inspect the existing documentation for shared references and draft behavior; done means the relevant documentation clearly explains the observed result.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.