From f6429c031b0f416e2915539661e2068d7887d16d Mon Sep 17 00:00:00 2001 From: Ricky Hanlon Date: Wed, 24 Jan 2024 00:07:45 -0500 Subject: [PATCH] Convert ReactCompositeComponentNestedState to createRoot --- ...ReactCompositeComponentNestedState-test.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactCompositeComponentNestedState-test.js b/packages/react-dom/src/__tests__/ReactCompositeComponentNestedState-test.js index 09c88ae815e75..596d4a5dfc99f 100644 --- a/packages/react-dom/src/__tests__/ReactCompositeComponentNestedState-test.js +++ b/packages/react-dom/src/__tests__/ReactCompositeComponentNestedState-test.js @@ -10,15 +10,17 @@ 'use strict'; let React; -let ReactDOM; +let ReactDOMClient; +let act; describe('ReactCompositeComponentNestedState-state', () => { beforeEach(() => { React = require('react'); - ReactDOM = require('react-dom'); + ReactDOMClient = require('react-dom/client'); + act = require('internal-test-utils').act; }); - it('should provide up to date values for props', () => { + it('should provide up to date values for props', async () => { class ParentComponent extends React.Component { state = {color: 'blue'}; @@ -96,11 +98,16 @@ describe('ReactCompositeComponentNestedState-state', () => { document.body.appendChild(container); const logger = jest.fn(); + const root = ReactDOMClient.createRoot(container); - void ReactDOM.render(, container); + await act(async () => { + root.render(); + }); - // click "light green" - container.childNodes[0].childNodes[3].click(); + await act(async () => { + // click "light green" + container.childNodes[0].childNodes[3].click(); + }); expect(logger.mock.calls).toEqual([ ['parent-render', 'blue'],