Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert ReactCompositeComponentNestedState to createRoot #28066

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'};

Expand Down Expand Up @@ -96,11 +98,16 @@ describe('ReactCompositeComponentNestedState-state', () => {
document.body.appendChild(container);

const logger = jest.fn();
const root = ReactDOMClient.createRoot(container);

void ReactDOM.render(<ParentComponent logger={logger} />, container);
await act(async () => {
root.render(<ParentComponent logger={logger} />);
});

// 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'],
Expand Down