Skip to content

Commit eb7d502

Browse files
committed
Wrap warnings to associate the cause
1 parent af4313b commit eb7d502

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

packages/react-reconciler/src/ReactFiberCommitEffects.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,14 @@ 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',
190-
hookName,
191-
addendum,
192-
);
187+
runWithFiberInDEV(finishedWork, () => {
188+
console.error(
189+
'%s must not return anything besides a function, ' +
190+
'which is used for clean-up.%s',
191+
hookName,
192+
addendum,
193+
);
194+
});
193195
}
194196
}
195197
}
@@ -642,11 +644,13 @@ export function commitClassSnapshot(finishedWork: Fiber, current: Fiber) {
642644
((didWarnAboutUndefinedSnapshotBeforeUpdate: any): Set<mixed>);
643645
if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) {
644646
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-
);
647+
runWithFiberInDEV(finishedWork, () => {
648+
console.error(
649+
'%s.getSnapshotBeforeUpdate(): A snapshot value (or null) ' +
650+
'must be returned. You have returned undefined.',
651+
getComponentNameFromFiber(finishedWork),
652+
);
653+
});
650654
}
651655
} else {
652656
snapshot = callGetSnapshotBeforeUpdates(

0 commit comments

Comments
 (0)