Skip to content

Commit 87b9e14

Browse files
committed
Wrap warnings to associate the cause
1 parent d803508 commit 87b9e14

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

packages/react-reconciler/src/ReactFiberCommitEffects.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,16 @@ export function commitHookEffectListMount(
184184
} else {
185185
addendum = ' You returned: ' + destroy;
186186
}
187-
console.error(
188-
'%s must not return anything besides a function, ' +
189-
'which is used for clean-up.%s',
187+
runWithFiberInDEV(
188+
finishedWork,
189+
(n, a) => {
190+
console.error(
191+
'%s must not return anything besides a function, ' +
192+
'which is used for clean-up.%s',
193+
n,
194+
a,
195+
);
196+
},
190197
hookName,
191198
addendum,
192199
);
@@ -642,11 +649,13 @@ export function commitClassSnapshot(finishedWork: Fiber, current: Fiber) {
642649
((didWarnAboutUndefinedSnapshotBeforeUpdate: any): Set<mixed>);
643650
if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
644651
didWarnSet.add(finishedWork.type);
645-
console.error(
646-
'%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' +
647-
'must be returned. You have returned undefined.',
648-
getComponentNameFromFiber(finishedWork),
649-
);
652+
runWithFiberInDEV(finishedWork, () => {
653+
console.error(
654+
'%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' +
655+
'must be returned. You have returned undefined.',
656+
getComponentNameFromFiber(finishedWork),
657+
);
658+
});
650659
}
651660
} else {
652661
snapshot = callGetSnapshotBeforeUpdates(

0 commit comments

Comments
 (0)