Skip to content

Commit

Permalink
Wrap user space calls in runWithFiberInDEV
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Sep 4, 2024
1 parent 5e8b486 commit b614e89
Showing 1 changed file with 42 additions and 7 deletions.
49 changes: 42 additions & 7 deletions packages/react-reconciler/src/ReactFiberCommitEffects.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ import {
callDestroyInDEV,
} from './ReactFiberCallUserSpace';

import {runWithFiberInDEV} from './ReactCurrentFiber';

function shouldProfile(current: Fiber): boolean {
return (
enableProfilerTimer &&
Expand Down Expand Up @@ -128,7 +130,7 @@ export function commitHookEffectListMount(
if ((flags & HookInsertion) !== NoHookEffect) {
setIsRunningInsertionEffect(true);
}
destroy = callCreateInDEV(effect);
destroy = runWithFiberInDEV(finishedWork, callCreateInDEV, effect);
if ((flags & HookInsertion) !== NoHookEffect) {
setIsRunningInsertionEffect(false);
}
Expand Down Expand Up @@ -330,7 +332,12 @@ export function commitClassLayoutLifecycles(
if (shouldProfile(finishedWork)) {
startLayoutEffectTimer();
if (__DEV__) {
callComponentDidMountInDEV(finishedWork, instance);
runWithFiberInDEV(
finishedWork,
callComponentDidMountInDEV,
finishedWork,
instance,
);
} else {
try {
instance.componentDidMount();
Expand All @@ -341,7 +348,12 @@ export function commitClassLayoutLifecycles(
recordLayoutEffectDuration(finishedWork);
} else {
if (__DEV__) {
callComponentDidMountInDEV(finishedWork, instance);
runWithFiberInDEV(
finishedWork,
callComponentDidMountInDEV,
finishedWork,
instance,
);
} else {
try {
instance.componentDidMount();
Expand Down Expand Up @@ -439,7 +451,12 @@ export function commitClassDidMount(finishedWork: Fiber) {
const instance = finishedWork.stateNode;
if (typeof instance.componentDidMount === 'function') {
if (__DEV__) {
callComponentDidMountInDEV(finishedWork, instance);
runWithFiberInDEV(
finishedWork,
callComponentDidMountInDEV,
finishedWork,
instance,
);
} else {
try {
instance.componentDidMount();
Expand Down Expand Up @@ -619,7 +636,13 @@ export function safelyCallComponentWillUnmount(
if (shouldProfile(current)) {
startLayoutEffectTimer();
if (__DEV__) {
callComponentWillUnmountInDEV(current, nearestMountedAncestor, instance);
runWithFiberInDEV(
current,
callComponentWillUnmountInDEV,
current,
nearestMountedAncestor,
instance,
);
} else {
try {
instance.componentWillUnmount();
Expand All @@ -630,7 +653,13 @@ export function safelyCallComponentWillUnmount(
recordLayoutEffectDuration(current);
} else {
if (__DEV__) {
callComponentWillUnmountInDEV(current, nearestMountedAncestor, instance);
runWithFiberInDEV(
current,
callComponentWillUnmountInDEV,
current,
nearestMountedAncestor,
instance,
);
} else {
try {
instance.componentWillUnmount();
Expand Down Expand Up @@ -761,7 +790,13 @@ export function safelyCallDestroy(
destroy: () => void,
) {
if (__DEV__) {
callDestroyInDEV(current, nearestMountedAncestor, destroy);
runWithFiberInDEV(
current,
callDestroyInDEV,
current,
nearestMountedAncestor,
destroy,
);
} else {
try {
destroy();
Expand Down

0 comments on commit b614e89

Please sign in to comment.