Skip to content

Commit c39ec17

Browse files
authored
Convert ReactErrorBoundariesHooks to createRoot (#28175)
1 parent 4bd5e3e commit c39ec17

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

packages/react-dom/src/__tests__/ReactErrorBoundariesHooks-test.internal.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@
1010
'use strict';
1111

1212
let React;
13-
let ReactDOM;
13+
let ReactDOMClient;
14+
let act;
1415

1516
describe('ReactErrorBoundariesHooks', () => {
1617
beforeEach(() => {
1718
jest.resetModules();
18-
ReactDOM = require('react-dom');
1919
React = require('react');
20+
ReactDOMClient = require('react-dom/client');
21+
act = require('internal-test-utils').act;
2022
});
2123

22-
it('should preserve hook order if errors are caught', () => {
24+
it('should preserve hook order if errors are caught', async () => {
2325
function ErrorThrower() {
2426
React.useMemo(() => undefined, []);
2527
throw new Error('expected');
@@ -57,10 +59,15 @@ describe('ReactErrorBoundariesHooks', () => {
5759
}
5860

5961
const container = document.createElement('div');
60-
ReactDOM.render(<App />, container);
62+
const root = ReactDOMClient.createRoot(container);
63+
await act(() => {
64+
root.render(<App />);
65+
});
6166

62-
expect(() => {
63-
ReactDOM.render(<App />, container);
64-
}).not.toThrow();
67+
await expect(
68+
act(() => {
69+
root.render(<App />);
70+
}),
71+
).resolves.not.toThrow();
6572
});
6673
});

0 commit comments

Comments
 (0)