From ddeb44534d4982ba77bc6a7cf436a583374691ce Mon Sep 17 00:00:00 2001 From: Jack Pope Date: Mon, 22 Jan 2024 14:36:44 -0500 Subject: [PATCH] Use createRoot for ReactTreeTraversal-test --- .../src/__tests__/ReactTreeTraversal-test.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js b/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js index 53be0cbdb2d6d..201c0fdeb8ee7 100644 --- a/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js +++ b/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js @@ -10,7 +10,7 @@ 'use strict'; let React; -let ReactDOM; +let ReactDOMClient; const ChildComponent = ({id, eventHandler}) => (
{ 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(); @@ -81,10 +83,14 @@ describe('ReactTreeTraversal', () => { document.body.appendChild(outerNode1); document.body.appendChild(outerNode2); - ReactDOM.render(, container); + root = ReactDOMClient.createRoot(container); + await act(() => { + root.render(); + }) }); afterEach(() => { + root.unmount(); document.body.removeChild(container); document.body.removeChild(outerNode1); document.body.removeChild(outerNode2);