Skip to content

Commit b85dd83

Browse files
committed
Ensure captureOwnerStack returns when no stack is available
1 parent cd90a4d commit b85dd83

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/react-reconciler/src/ReactCurrentFiber.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function runWithFiberInDEV<A0, A1, A2, A3, A4, T>(
7272
}
7373
return callback(arg0, arg1, arg2, arg3, arg4);
7474
} finally {
75-
current = previousFiber;
75+
setCurrentFiber(previousFiber);
7676
}
7777
}
7878
// These errors should never make it into a build so we don't need to encode them in codes.json

packages/react-reconciler/src/__tests__/ReactOwnerStacks-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,14 @@ describe('ReactOwnerStacks', () => {
6262
'\n in Bar (at **)' + '\n in Foo (at **)',
6363
);
6464
});
65+
66+
it('returns null outside of render', async () => {
67+
expect(React.captureOwnerStack()).toBe(null);
68+
69+
await act(() => {
70+
ReactNoop.render(<div></div>);
71+
});
72+
73+
expect(React.captureOwnerStack()).toBe(null);
74+
});
6575
});

0 commit comments

Comments
 (0)