You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
current creates a copy of nested objects, even when such objects are not draft.
Consider the following example:
constobj={k: 42};constoriginal={x: {y: {z: [obj]}}}constyReplace={z: [obj]};// with createconstwithCreate=create(original,draft=>{draft.x.y=yReplace;});console.log(withCreate.x.y===yReplace)// prints trueconsole.log(withCreate.x.y.z[0]===obj)// prints true// with draft + currentconst[draft]=create(original);draft.x.y=yReplace;constwithDraft=current(draft);console.log(withDraft.x.y===yReplace)// prints falseconsole.log(withDraft.x.y.z[0]===obj)// prints false! DEEP COPY???
I would expect the draft + current to behave like the create option, returning the new object, but currently actually performs a deep copy instead. This has a big negative impact on the performance of current
The text was updated successfully, but these errors were encountered:
current
creates a copy of nested objects, even when such objects are not draft.Consider the following example:
I would expect the draft + current to behave like the create option, returning the new object, but currently actually performs a deep copy instead. This has a big negative impact on the performance of
current
The text was updated successfully, but these errors were encountered: