Skip to content

Commit

Permalink
Concurrent rendering in ReactDevToolsHooksIntegration-test (facebook#…
Browse files Browse the repository at this point in the history
…28522)

## Summary

We need to unblock flipping the default for RTR to be concurrent
rendering. Update ReactDevToolsHooksIntegration-test to use
`unstable_isConcurrent` in place.

## How did you test this change?

`yarn test
packages/react-debug-tools/src/__tests__/ReactDevToolsHooksIntegration-test.js`
  • Loading branch information
jackpope authored and AndyPengc12 committed Apr 15, 2024
1 parent 7a5df10 commit 635bdcb
Showing 1 changed file with 31 additions and 14 deletions.
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

0 comments on commit 635bdcb

Please sign in to comment.