Skip to content

Commit

Permalink
refactor(current): update
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Mar 26, 2023
1 parent 08f795a commit 8fff243
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/current.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export function handleReturnValue<T extends object>(
forEach(value, (key, item, source) => {
const proxyDraft = getProxyDraft(item);
// just handle the draft which is created by the same rootDraft
if (proxyDraft && proxyDraft?.finalities === rootDraft?.finalities) {
if (
proxyDraft &&
rootDraft &&
proxyDraft.finalities === rootDraft.finalities
) {
isContainDraft = true;
if (__DEV__ && warning) {
console.warn(
Expand Down
2 changes: 1 addition & 1 deletion test/immer/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ function runBaseTest(

// Modified parent test
parent.c = 1;
expect(produce({}, () => [parent.b])[0]).toBe(parent.b);
expect(produce(null, () => [parent.b])[0]).toBe(parent.b);
parent.b.x; // Ensure proxy not revoked.
});
});
Expand Down

0 comments on commit 8fff243

Please sign in to comment.