Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concurrent rendering in ReactDevToolsHooksIntegration-test #28522

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('React hooks DevTools integration', () => {
const InternalTestUtils = require('internal-test-utils');
waitForAll = InternalTestUtils.waitForAll;

act = ReactTestRenderer.act;
act = require('internal-test-utils').act;
});

it('should support editing useState hooks', async () => {
Expand All @@ -55,7 +55,12 @@ describe('React hooks DevTools integration', () => {
return <div>count:{count}</div>;
}

const renderer = ReactTestRenderer.create(<MyComponent />);
let renderer;
await act(() => {
renderer = ReactTestRenderer.create(<MyComponent />, {
unstable_isConcurrent: true,
});
});
expect(renderer.toJSON()).toEqual({
type: 'div',
props: {},
Expand Down Expand Up @@ -107,7 +112,12 @@ describe('React hooks DevTools integration', () => {
);
}

const renderer = ReactTestRenderer.create(<MyComponent />);
let renderer;
await act(() => {
renderer = ReactTestRenderer.create(<MyComponent />, {
unstable_isConcurrent: true,
});
});
expect(renderer.toJSON()).toEqual({
type: 'div',
props: {},
Expand Down Expand Up @@ -155,7 +165,12 @@ describe('React hooks DevTools integration', () => {
return <div>count:{count}</div>;
}

const renderer = ReactTestRenderer.create(<MyComponent />);
let renderer;
await act(() => {
renderer = ReactTestRenderer.create(<MyComponent />, {
unstable_isConcurrent: true,
});
});
expect(renderer.toJSON()).toEqual({
type: 'div',
props: {},
Expand Down Expand Up @@ -192,14 +207,17 @@ describe('React hooks DevTools integration', () => {
function MyComponent() {
return 'Done';
}

const renderer = ReactTestRenderer.create(
<div>
<React.Suspense fallback={'Loading'}>
<MyComponent />
</React.Suspense>
</div>,
);
let renderer;
await act(() => {
renderer = ReactTestRenderer.create(
<div>
<React.Suspense fallback={'Loading'}>
<MyComponent />
</React.Suspense>
</div>,
{unstable_isConcurrent: true},
);
});
const fiber = renderer.root._currentFiber().child;
if (__DEV__) {
// First render was locked
Expand Down Expand Up @@ -236,7 +254,6 @@ describe('React hooks DevTools integration', () => {
}
});

// @gate __DEV__
it('should support overriding suspense in concurrent mode', async () => {
if (__DEV__) {
// Lock the first render
Expand All @@ -254,7 +271,7 @@ describe('React hooks DevTools integration', () => {
<MyComponent />
</React.Suspense>
</div>,
{isConcurrent: true},
{unstable_isConcurrent: true},
),
);

Expand Down