Skip to content

Commit

Permalink
consider whether value is an object
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff committed Dec 3, 2022
1 parent b474788 commit 93543f3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/react-reconciler/src/ReactCapturedValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,24 @@ export function createCapturedValueAtFiber<T>(
value: T,
source: Fiber,
): CapturedValue<T> {
if (!hasOwnProperty.call(value, '_componentStack')) {
(value: any)._componentStack = getStackByFiberInDevAndProd(source);
let stack;
if (value && typeof value === 'object') {
if (hasOwnProperty.call(value, '_componentStack')) {
stack = (value._componentStack: any);
} else {
stack = (value: any)._componentStack = getStackByFiberInDevAndProd(
source,
);
}
} else {
stack = getStackByFiberInDevAndProd(source);
}
// If the value is an error, call this function immediately after it is thrown
// so the stack is accurate.
return {
value,
source,
stack: (value: any)._componentStack,
stack,
digest: null,
};
}
Expand Down

0 comments on commit 93543f3

Please sign in to comment.