mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Ensure captureOwnerStack returns null when no stack is available (#32353)
Co-authored-by: Younes Henni <youneshenniwrites@gmail.com>
This commit is contained in:
co-authored by
Younes Henni
parent
cbbe8666a8
commit
c6a7e18636
+1
-1
@@ -72,7 +72,7 @@ export function runWithFiberInDEV<A0, A1, A2, A3, A4, T>(
|
||||
}
|
||||
return callback(arg0, arg1, arg2, arg3, arg4);
|
||||
} finally {
|
||||
current = previousFiber;
|
||||
setCurrentFiber(previousFiber);
|
||||
}
|
||||
}
|
||||
// These errors should never make it into a build so we don't need to encode them in codes.json
|
||||
|
||||
@@ -62,4 +62,17 @@ describe('ReactOwnerStacks', () => {
|
||||
'\n in Bar (at **)' + '\n in Foo (at **)',
|
||||
);
|
||||
});
|
||||
|
||||
it('returns null outside of render', async () => {
|
||||
// Awkward to gate since some builds will have `captureOwnerStack` return null in prod
|
||||
if (__DEV__ && gate('enableOwnerStacks')) {
|
||||
expect(React.captureOwnerStack()).toBe(null);
|
||||
|
||||
await act(() => {
|
||||
ReactNoop.render(<div />);
|
||||
});
|
||||
|
||||
expect(React.captureOwnerStack()).toBe(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user