Convert ReactErrorBoundariesHooks to createRoot (#28175)

This commit is contained in:
Sebastian Silbermann authored and GitHub committed 2024-02-01 18:48:58 -05:00
1 parent 4bd5e3ea5c
commit c39ec17e66
1 file changed
+14 -7
@@ -10,16 +10,18 @@
'use strict';
let React;
let ReactDOM;
let ReactDOMClient;
let act;
describe('ReactErrorBoundariesHooks', () => {
beforeEach(() => {
jest.resetModules();
ReactDOM = require('react-dom');
React = require('react');
ReactDOMClient = require('react-dom/client');
act = require('internal-test-utils').act;
});
it('should preserve hook order if errors are caught', () => {
it('should preserve hook order if errors are caught', async () => {
function ErrorThrower() {
React.useMemo(() => undefined, []);
throw new Error('expected');
@@ -57,10 +59,15 @@ describe('ReactErrorBoundariesHooks', () => {
}
const container = document.createElement('div');
ReactDOM.render(<App />, container);
const root = ReactDOMClient.createRoot(container);
await act(() => {
root.render(<App />);
});
expect(() => {
ReactDOM.render(<App />, container);
}).not.toThrow();
await expect(
act(() => {
root.render(<App />);
}),
).resolves.not.toThrow();
});
});