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 af4313b commit eb7d502
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions packages/react-reconciler/src/ReactFiberCommitEffects.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,14 @@ 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',
hookName,
addendum,
);
runWithFiberInDEV(finishedWork, () => {
console.error(
'%s must not return anything besides a function, ' +
'which is used for clean-up.%s',
hookName,
addendum,
);
});
}
}
}
Expand Down Expand Up @@ -642,11 +644,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 eb7d502

Please sign in to comment.