Skip to content

Commit

Permalink
Only concurrent render in RTR
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Pope committed Mar 20, 2024
1 parent ddf78a7 commit ff31942
Show file tree
Hide file tree
Showing 16 changed files with 441 additions and 239 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ describe('DebugTracing', () => {
<React.unstable_DebugTracingMode>
<div />
</React.unstable_DebugTracingMode>,
{unstable_isConcurrent: true},

),
);
expect(logs).toEqual([]);
Expand Down Expand Up @@ -180,6 +182,10 @@ describe('DebugTracing', () => {
<Example />
</React.Suspense>
</React.unstable_DebugTracingMode>,
<<<<<<< HEAD
=======
{unstable_isConcurrent: true},
>>>>>>> b81de30fc (Flip default to concurrent render in RTR)
),
);

Expand Down Expand Up @@ -216,6 +222,7 @@ describe('DebugTracing', () => {
</React.Suspense>
</Wrapper>
</React.unstable_DebugTracingMode>,
{unstable_isConcurrent: true},
),
);

Expand Down Expand Up @@ -246,6 +253,7 @@ describe('DebugTracing', () => {
<React.unstable_DebugTracingMode>
<Example />
</React.unstable_DebugTracingMode>,
{unstable_isConcurrent: true},
),
);

Expand Down Expand Up @@ -276,11 +284,10 @@ describe('DebugTracing', () => {
<React.unstable_DebugTracingMode>
<Example />
</React.unstable_DebugTracingMode>,
);
});
}).toErrorDev(
'Warning: Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.',
);
{unstable_isConcurrent: true},
),
);
}).toErrorDev('Cannot update during an existing state transition');

expect(logs).toEqual([
`group: ⚛️ render (${DEFAULT_LANE_STRING})`,
Expand All @@ -304,6 +311,7 @@ describe('DebugTracing', () => {
<React.unstable_DebugTracingMode>
<Example />
</React.unstable_DebugTracingMode>,
{unstable_isConcurrent: true},
),
);

Expand Down Expand Up @@ -331,6 +339,7 @@ describe('DebugTracing', () => {
<React.unstable_DebugTracingMode>
<Example />
</React.unstable_DebugTracingMode>,
{unstable_isConcurrent: true},
);
});
expect(logs).toEqual([
Expand All @@ -355,6 +364,7 @@ describe('DebugTracing', () => {
<React.unstable_DebugTracingMode>
<Example />
</React.unstable_DebugTracingMode>,
{unstable_isConcurrent: true},
);
});

Expand All @@ -377,6 +387,7 @@ describe('DebugTracing', () => {
<React.unstable_DebugTracingMode>
<Example />
</React.unstable_DebugTracingMode>,
{unstable_isConcurrent: true},
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ describe('ReactHooks', () => {
}).rejects.toThrow('Hello');

if (__DEV__) {
expect(console.error).toHaveBeenCalledTimes(2);
expect(jest.mocked(console.error)).toHaveBeenCalledTimes(2);
expect(console.error.mock.calls[0][0]).toContain(
'Warning: Cannot update a component (`%s`) while rendering ' +
'a different component (`%s`).',
Expand Down
7 changes: 4 additions & 3 deletions packages/react-test-renderer/src/ReactTestRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {ConcurrentRoot, LegacyRoot} from 'react-reconciler/src/ReactRootTags';
import {
allowConcurrentByDefault,
enableReactTestRendererWarning,
enableReactTestRendererLegacyMode,
} from 'shared/ReactFeatureFlags';

const act = React.act;
Expand Down Expand Up @@ -482,16 +483,16 @@ function create(
}

let createNodeMock = defaultTestOptions.createNodeMock;
let isConcurrent = false;
let isConcurrent = true;
let isStrictMode = false;
let concurrentUpdatesByDefault = null;
if (typeof options === 'object' && options !== null) {
if (typeof options.createNodeMock === 'function') {
// $FlowFixMe[incompatible-type] found when upgrading Flow
createNodeMock = options.createNodeMock;
}
if (options.unstable_isConcurrent === true) {
isConcurrent = true;
if (enableReactTestRendererLegacyMode) {
isConcurrent = options.unstable_isConcurrent;
}
if (options.unstable_strictMode === true) {
isStrictMode = true;
Expand Down
Loading

0 comments on commit ff31942

Please sign in to comment.