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 ddeb445
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 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,7 @@
'use strict';

let React;
let ReactDOM;
let ReactDOMClient;

const ChildComponent = ({id, eventHandler}) => (
<div
Expand Down Expand Up @@ -67,10 +67,12 @@ describe('ReactTreeTraversal', () => {
let container;
let outerNode1;
let outerNode2;
let root;

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 +83,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 ddeb445

Please sign in to comment.