Skip to content

Commit

Permalink
Wrap warnings to associate the cause
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Sep 4, 2024
1 parent d803508 commit 8ca51d6
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions packages/react-reconciler/src/ReactFiberCommitEffects.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,16 @@ export function commitHookEffectListMount(
} else {
addendum = ' You returned: ' + destroy;
}
console.error(
'%s must not return anything besides a function, ' +
'which is used for clean-up.%s',
runWithFiberInDEV(
finishedWork,
(n, a) => {
console.error(
'%s must not return anything besides a function, ' +
'which is used for clean-up.%s',
n,
a,
);
},
hookName,
addendum,
);
Expand Down Expand Up @@ -642,11 +649,13 @@ export function commitClassSnapshot(finishedWork: Fiber, current: Fiber) {
((didWarnAboutUndefinedSnapshotBeforeUpdate: any): Set<mixed>);
if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
didWarnSet.add(finishedWork.type);
console.error(
'%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' +
'must be returned. You have returned undefined.',
getComponentNameFromFiber(finishedWork),
);
runWithFiberInDEV(finishedWork, () => {
console.error(
'%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' +
'must be returned. You have returned undefined.',
getComponentNameFromFiber(finishedWork),
);
});
}
} else {
snapshot = callGetSnapshotBeforeUpdates(
Expand Down

0 comments on commit 8ca51d6

Please sign in to comment.