Skip to content

Commit

Permalink
Remove createRootStrictEffectsByDefault flag (facebook#28102)
Browse files Browse the repository at this point in the history
There's no need to separate strict mode from strict effects mode any
more.

I didn't clean up the `StrictEffectMode` fiber flag, because it's used
to prevent strict effects in legacy mode. I could replace those checks
with `LegacyMode` checks, but when we remove legacy mode, we can remove
that flag and condense them into one StrictMode flag away.
  • Loading branch information
rickhanlonii authored and AndyPengc12 committed Apr 15, 2024
1 parent c98faa7 commit 30bb931
Show file tree
Hide file tree
Showing 12 changed files with 248 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -776,14 +776,7 @@ describe('ReactDOMServerPartialHydration', () => {
const span2 = container.getElementsByTagName('span')[0];
// This is a new node.
expect(span).not.toBe(span2);

if (gate(flags => flags.dfsEffectsRefactor)) {
// The effects list refactor causes this to be null because the Suspense Activity's child
// is null. However, since we can't hydrate Suspense in legacy this change in behavior is ok
expect(ref.current).toBe(null);
} else {
expect(ref.current).toBe(span2);
}
expect(ref.current).toBe(null);

// Resolving the promise should render the final content.
suspend = false;
Expand Down
3 changes: 1 addition & 2 deletions packages/react-reconciler/src/ReactFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
isHostSingletonType,
} from './ReactFiberConfig';
import {
createRootStrictEffectsByDefault,
enableCache,
enableProfilerTimer,
enableScopeAPI,
Expand Down Expand Up @@ -456,7 +455,7 @@ export function createHostRootFiber(
let mode;
if (tag === ConcurrentRoot) {
mode = ConcurrentMode;
if (isStrictMode === true || createRootStrictEffectsByDefault) {
if (isStrictMode === true) {
mode |= StrictLegacyMode | StrictEffectsMode;
}
if (
Expand Down
Loading

0 comments on commit 30bb931

Please sign in to comment.