Skip to content

Commit

Permalink
Update isConcurrent RTR option usage (#28546)
Browse files Browse the repository at this point in the history
Reverting some of #27804 which
renamed this option to stable. This PR just replaces internal usage to
make upcoming PRs cleaner.

Keeping isConcurrent unstable for the next major release in order to
enable a broader deprecation of RTR and be consistent with concurrent
rendering everywhere for next major.
(#28498)
- Next major will use concurrent root
- The old behavior (legacy root by default, concurrent root with
unstable option) will be preserved for React Native until new
architecture is fully shipped.
- Flag and legacy root usage can be removed after RN dependency is
unblocked without an additional breaking change
  • Loading branch information
jackpope committed Mar 18, 2024
1 parent b09e102 commit 3832730
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ describe('ReactHooksInspectionIntegration', () => {
);
}
const renderer = await act(() => {
return ReactTestRenderer.create(<Foo />, {isConcurrent: true});
return ReactTestRenderer.create(<Foo />, {unstable_isConcurrent: true});
});
expect(renderer).toMatchRenderedOutput(null);
let childFiber = renderer.root.findByType(Foo)._currentFiber();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('InspectedElement', () => {
// Used by inspectElementAtIndex() helper function
utils.act(() => {
testRendererInstance = TestRenderer.create(null, {
isConcurrent: true,
unstable_isConcurrent: true,
});
});

Expand Down Expand Up @@ -356,7 +356,7 @@ describe('InspectedElement', () => {
['An update to %s inside a test was not wrapped in act'],
() => {
testRendererInstance = TestRenderer.create(null, {
isConcurrent: true,
unstable_isConcurrent: true,
});
},
);
Expand Down Expand Up @@ -510,7 +510,7 @@ describe('InspectedElement', () => {
['An update to %s inside a test was not wrapped in act'],
() => {
testRendererInstance = TestRenderer.create(null, {
isConcurrent: true,
unstable_isConcurrent: true,
});
},
);
Expand Down Expand Up @@ -2069,7 +2069,7 @@ describe('InspectedElement', () => {
['An update to %s inside a test was not wrapped in act'],
() => {
testRendererInstance = TestRenderer.create(null, {
isConcurrent: true,
unstable_isConcurrent: true,
});
},
);
Expand Down Expand Up @@ -2129,7 +2129,7 @@ describe('InspectedElement', () => {
['An update to %s inside a test was not wrapped in act'],
() => {
testRendererInstance = TestRenderer.create(null, {
isConcurrent: true,
unstable_isConcurrent: true,
});
},
);
Expand Down Expand Up @@ -2405,7 +2405,7 @@ describe('InspectedElement', () => {
<Suspender target={id} />
</React.Suspense>
</Contexts>,
{isConcurrent: true},
{unstable_isConcurrent: true},
);
}, false);
await utils.actAsync(() => {
Expand Down Expand Up @@ -2943,7 +2943,7 @@ describe('InspectedElement', () => {
['An update to %s inside a test was not wrapped in act'],
() => {
testRendererInstance = TestRenderer.create(null, {
isConcurrent: true,
unstable_isConcurrent: true,
});
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('ErrorBoundaryReconciliation', () => {
<ErrorBoundary fallbackTagName={fallbackTagName}>
<BrokenRender fail={false} />
</ErrorBoundary>,
{isConcurrent: isConcurrent},
{unstable_isConcurrent: isConcurrent},
);
});
expect(renderer).toMatchRenderedOutput(<span prop="BrokenRender" />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('ReactHooks', () => {
return <Child text={text} />;
}

const root = ReactTestRenderer.create(null, {isConcurrent: true});
const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
root.update(<Parent />);
await waitForAll(['Parent: 0, 0', 'Child: 0, 0', 'Effect: 0, 0']);
expect(root).toMatchRenderedOutput('0, 0');
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('ReactHooks', () => {

Parent = memo(Parent);

const root = ReactTestRenderer.create(null, {isConcurrent: true});
const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
root.update(<Parent theme="light" />);
await waitForAll(['Parent: 0, 0 (light)', 'Child: 0, 0 (light)']);
expect(root).toMatchRenderedOutput('0, 0 (light)');
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('ReactHooks', () => {
return counter;
}

const root = ReactTestRenderer.create(null, {isConcurrent: true});
const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
root.update(<Counter />);
await waitForAll(['Count: 0']);
expect(root).toMatchRenderedOutput('0');
Expand Down Expand Up @@ -266,7 +266,7 @@ describe('ReactHooks', () => {
return counter;
}

const root = ReactTestRenderer.create(null, {isConcurrent: true});
const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
root.update(<Counter />);
await waitForAll(['Count: 0']);
expect(root).toMatchRenderedOutput('0');
Expand Down Expand Up @@ -322,7 +322,7 @@ describe('ReactHooks', () => {
});
return <Child text={text} />;
}
const root = ReactTestRenderer.create(null, {isConcurrent: true});
const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
await act(() => {
root.update(
<ThemeProvider>
Expand Down Expand Up @@ -390,7 +390,7 @@ describe('ReactHooks', () => {
return <Child text={counter} />;
}

const root = ReactTestRenderer.create(null, {isConcurrent: true});
const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
root.update(<Parent />);
await waitForAll(['Parent: 0', 'Child: 0', 'Effect: 0']);
expect(root).toMatchRenderedOutput('0');
Expand Down Expand Up @@ -465,7 +465,7 @@ describe('ReactHooks', () => {
return <Child text={counter} />;
}

const root = ReactTestRenderer.create(null, {isConcurrent: true});
const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
root.update(<Parent />);
await waitForAll(['Parent: 0', 'Child: 0']);
expect(root).toMatchRenderedOutput('0');
Expand Down Expand Up @@ -523,7 +523,7 @@ describe('ReactHooks', () => {
return <Child text={counter} />;
}

const root = ReactTestRenderer.create(null, {isConcurrent: true});
const root = ReactTestRenderer.create(null, {unstable_isConcurrent: true});
root.update(<Parent />);
await waitForAll(['Parent: 1', 'Child: 1']);
expect(root).toMatchRenderedOutput('1');
Expand Down
50 changes: 25 additions & 25 deletions packages/react-reconciler/src/__tests__/ReactLazy-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('ReactLazy', () => {
<LazyText text="Hi" />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand Down Expand Up @@ -179,7 +179,7 @@ describe('ReactLazy', () => {
<LazyBar />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand All @@ -202,7 +202,7 @@ describe('ReactLazy', () => {
const LazyText = lazy(async () => Text);

const root = ReactTestRenderer.create(null, {
isConcurrent: true,
unstable_isConcurrent: true,
});

let error;
Expand Down Expand Up @@ -236,7 +236,7 @@ describe('ReactLazy', () => {
});

const root = ReactTestRenderer.create(null, {
isConcurrent: true,
unstable_isConcurrent: true,
});

let error;
Expand Down Expand Up @@ -296,7 +296,7 @@ describe('ReactLazy', () => {
}

const root = ReactTestRenderer.create(<Parent swap={false} />, {
isConcurrent: true,
unstable_isConcurrent: true,
});

await waitForAll(['Suspend! [LazyChildA]', 'Loading...']);
Expand Down Expand Up @@ -331,7 +331,7 @@ describe('ReactLazy', () => {
<LazyText />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand Down Expand Up @@ -388,7 +388,7 @@ describe('ReactLazy', () => {
</Lazy>
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);
await waitForAll(['Loading...']);
Expand Down Expand Up @@ -434,7 +434,7 @@ describe('ReactLazy', () => {
</Suspense>
</>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);
await waitForAll(['Not lazy: 0', 'Loading...']);
Expand Down Expand Up @@ -479,7 +479,7 @@ describe('ReactLazy', () => {
</Suspense>
</>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);
await waitForAll(['Not lazy: 0', 'Loading...']);
Expand Down Expand Up @@ -555,7 +555,7 @@ describe('ReactLazy', () => {
<LazyClass num={1} />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand Down Expand Up @@ -685,7 +685,7 @@ describe('ReactLazy', () => {
<LazyText />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand Down Expand Up @@ -728,7 +728,7 @@ describe('ReactLazy', () => {
<BadLazy />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand All @@ -755,7 +755,7 @@ describe('ReactLazy', () => {
<Lazy2 text="Hello" />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand Down Expand Up @@ -788,7 +788,7 @@ describe('ReactLazy', () => {
<LazyAdd inner="2" outer="2" />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand Down Expand Up @@ -935,7 +935,7 @@ describe('ReactLazy', () => {
<LazyText />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand Down Expand Up @@ -973,7 +973,7 @@ describe('ReactLazy', () => {
<LazyFoo />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand Down Expand Up @@ -1018,7 +1018,7 @@ describe('ReactLazy', () => {
<LazyForwardRef ref={ref} />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand Down Expand Up @@ -1049,7 +1049,7 @@ describe('ReactLazy', () => {
<LazyAdd outer={2} />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);
await waitForAll(['Loading...']);
Expand Down Expand Up @@ -1136,7 +1136,7 @@ describe('ReactLazy', () => {
<LazyAdd outer={2} />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);
await waitForAll(['Loading...']);
Expand Down Expand Up @@ -1183,7 +1183,7 @@ describe('ReactLazy', () => {
<LazyFoo ref={ref} />
</Suspense>,
{
isConcurrent: true,
unstable_isConcurrent: true,
},
);

Expand Down Expand Up @@ -1223,7 +1223,7 @@ describe('ReactLazy', () => {
<LazyText text="Hi" />
</Suspense>
</ErrorBoundary>,
{isConcurrent: true},
{unstable_isConcurrent: true},
);

await waitForAll(['Loading...']);
Expand Down Expand Up @@ -1331,7 +1331,7 @@ describe('ReactLazy', () => {
}

const root = ReactTestRenderer.create(<Parent swap={false} />, {
isConcurrent: true,
unstable_isConcurrent: true,
});

await waitForAll(['Init A', 'Loading...']);
Expand Down Expand Up @@ -1416,7 +1416,7 @@ describe('ReactLazy', () => {
}

const root = ReactTestRenderer.create(<Parent swap={false} />, {
isConcurrent: false,
unstable_isConcurrent: false,
});

assertLog(['Init A', 'Init B', 'Loading...']);
Expand Down Expand Up @@ -1478,7 +1478,7 @@ describe('ReactLazy', () => {
}

const root = ReactTestRenderer.create(<Parent swap={false} />, {
isConcurrent: true,
unstable_isConcurrent: true,
});

await waitForAll(['Init A', 'Loading...']);
Expand Down Expand Up @@ -1547,7 +1547,7 @@ describe('ReactLazy', () => {
}

const root = ReactTestRenderer.create(<Parent swap={false} />, {
isConcurrent: false,
unstable_isConcurrent: false,
});

assertLog(['Init A', 'Loading...']);
Expand Down
6 changes: 1 addition & 5 deletions packages/react-test-renderer/src/ReactTestRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const act = React.act;

type TestRendererOptions = {
createNodeMock: (element: React$Element<any>) => any,
isConcurrent: boolean,
unstable_isConcurrent: boolean,
unstable_strictMode: boolean,
unstable_concurrentUpdatesByDefault: boolean,
Expand Down Expand Up @@ -491,10 +490,7 @@ function create(
// $FlowFixMe[incompatible-type] found when upgrading Flow
createNodeMock = options.createNodeMock;
}
if (
options.unstable_isConcurrent === true ||
options.isConcurrent === true
) {
if (options.unstable_isConcurrent === true) {
isConcurrent = true;
}
if (options.unstable_strictMode === true) {
Expand Down
Loading

0 comments on commit 3832730

Please sign in to comment.