Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Wrap user space calls in runWithFiberInDEV
  • Loading branch information
sebmarkbage committed Sep 6, 2024
commit 1de0845e15d3fbcc2ad0038cf38c758fda87d261
57 changes: 48 additions & 9 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 @@ -391,7 +403,9 @@ export function commitClassLayoutLifecycles(
if (shouldProfile(finishedWork)) {
startLayoutEffectTimer();
if (__DEV__) {
callComponentDidUpdateInDEV(
runWithFiberInDEV(
finishedWork,
callComponentDidUpdateInDEV,
finishedWork,
instance,
prevProps,
Expand All @@ -412,7 +426,9 @@ export function commitClassLayoutLifecycles(
recordLayoutEffectDuration(finishedWork);
} else {
if (__DEV__) {
callComponentDidUpdateInDEV(
runWithFiberInDEV(
finishedWork,
callComponentDidUpdateInDEV,
finishedWork,
instance,
prevProps,
Expand All @@ -439,7 +455,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 +640,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 +657,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 +794,13 @@ export function safelyCallDestroy(
destroy: () => void,
) {
if (__DEV__) {
callDestroyInDEV(current, nearestMountedAncestor, destroy);
runWithFiberInDEV(
current,
callDestroyInDEV,
current,
nearestMountedAncestor,
destroy,
);
} else {
try {
destroy();
Expand Down