Skip to content

Commit 5d1ce65

Browse files
authored
Align StrictMode behaviour with production (#25049)
* Skip double invoking effects in Offscreen * Run yarn replace-fork * Use executionContext to disable profiler timer * Restructure recursion into two functions * Fix ReactStrictMode test * Use gate pragma in ReacetOffscreenStrictMode test * Set and reset current debug fiber in dev * Skip over paths that don't include any insertions * Extract common logic to check for profiling to a helper function * Remove hasPassiveEffects flag from StrictMode * Fix flow issues * Revert "Skip over paths that don't include any insertions"
1 parent 9e67e7a commit 5d1ce65

10 files changed

+376
-557
lines changed

packages/react-reconciler/src/ReactChildFiber.new.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import type {Fiber} from './ReactInternalTypes';
1313
import type {Lanes} from './ReactFiberLane.new';
1414

1515
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
16-
import {Placement, ChildDeletion, Forked} from './ReactFiberFlags';
16+
import {
17+
Placement,
18+
ChildDeletion,
19+
Forked,
20+
PlacementDEV,
21+
} from './ReactFiberFlags';
1722
import {
1823
getIteratorFn,
1924
REACT_ELEMENT_TYPE,
@@ -343,15 +348,15 @@ function ChildReconciler(shouldTrackSideEffects) {
343348
const oldIndex = current.index;
344349
if (oldIndex < lastPlacedIndex) {
345350
// This is a move.
346-
newFiber.flags |= Placement;
351+
newFiber.flags |= Placement | PlacementDEV;
347352
return lastPlacedIndex;
348353
} else {
349354
// This item can stay in place.
350355
return oldIndex;
351356
}
352357
} else {
353358
// This is an insertion.
354-
newFiber.flags |= Placement;
359+
newFiber.flags |= Placement | PlacementDEV;
355360
return lastPlacedIndex;
356361
}
357362
}
@@ -360,7 +365,7 @@ function ChildReconciler(shouldTrackSideEffects) {
360365
// This is simpler for the single child case. We only need to do a
361366
// placement for inserting new children.
362367
if (shouldTrackSideEffects && newFiber.alternate === null) {
363-
newFiber.flags |= Placement;
368+
newFiber.flags |= Placement | PlacementDEV;
364369
}
365370
return newFiber;
366371
}

packages/react-reconciler/src/ReactChildFiber.old.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ import type {Fiber} from './ReactInternalTypes';
1313
import type {Lanes} from './ReactFiberLane.old';
1414

1515
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
16-
import {Placement, ChildDeletion, Forked} from './ReactFiberFlags';
16+
import {
17+
Placement,
18+
ChildDeletion,
19+
Forked,
20+
PlacementDEV,
21+
} from './ReactFiberFlags';
1722
import {
1823
getIteratorFn,
1924
REACT_ELEMENT_TYPE,
@@ -343,15 +348,15 @@ function ChildReconciler(shouldTrackSideEffects) {
343348
const oldIndex = current.index;
344349
if (oldIndex < lastPlacedIndex) {
345350
// This is a move.
346-
newFiber.flags |= Placement;
351+
newFiber.flags |= Placement | PlacementDEV;
347352
return lastPlacedIndex;
348353
} else {
349354
// This item can stay in place.
350355
return oldIndex;
351356
}
352357
} else {
353358
// This is an insertion.
354-
newFiber.flags |= Placement;
359+
newFiber.flags |= Placement | PlacementDEV;
355360
return lastPlacedIndex;
356361
}
357362
}
@@ -360,7 +365,7 @@ function ChildReconciler(shouldTrackSideEffects) {
360365
// This is simpler for the single child case. We only need to do a
361366
// placement for inserting new children.
362367
if (shouldTrackSideEffects && newFiber.alternate === null) {
363-
newFiber.flags |= Placement;
368+
newFiber.flags |= Placement | PlacementDEV;
364369
}
365370
return newFiber;
366371
}

0 commit comments

Comments
 (0)