Skip to content

Commit

Permalink
Use createRoot for ReactTreeTraversal-test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Pope committed Jan 22, 2024
1 parent b300304 commit 2c11ee6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/react-dom/src/__tests__/ReactTreeTraversal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
'use strict';

let React;
let ReactDOM;
let ReactDOMClient;
let act;
let root;

const ChildComponent = ({id, eventHandler}) => (
<div
Expand Down Expand Up @@ -68,9 +70,10 @@ describe('ReactTreeTraversal', () => {
let outerNode1;
let outerNode2;

beforeEach(() => {
beforeEach(async () => {
React = require('react');
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
act = require('internal-test-utils').act;

mockFn.mockReset();

Expand All @@ -81,10 +84,14 @@ describe('ReactTreeTraversal', () => {
document.body.appendChild(outerNode1);
document.body.appendChild(outerNode2);

ReactDOM.render(<ParentComponent eventHandler={mockFn} />, container);
root = ReactDOMClient.createRoot(container);
await act(() => {
root.render(<ParentComponent eventHandler={mockFn} />);
})
});

afterEach(() => {
root.unmount();
document.body.removeChild(container);
document.body.removeChild(outerNode1);
document.body.removeChild(outerNode2);
Expand Down

0 comments on commit 2c11ee6

Please sign in to comment.