Skip to content

Commit

Permalink
Convert ReactJSXElementValidator to createRoot (#28209)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii authored and gaearon committed Feb 3, 2024
1 parent 1313715 commit f5e57a2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/react/src/__tests__/ReactJSXElementValidator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
// of dynamic errors when using JSX with Flow.
let React;
let ReactDOM;
let ReactDOMClient;
let ReactTestUtils;
let PropTypes;
let act;

describe('ReactJSXElementValidator', () => {
let Component;
Expand All @@ -26,7 +28,9 @@ describe('ReactJSXElementValidator', () => {
PropTypes = require('prop-types');
React = require('react');
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
ReactTestUtils = require('react-dom/test-utils');
act = require('internal-test-utils').act;

Component = class extends React.Component {
render() {
Expand Down Expand Up @@ -172,7 +176,7 @@ describe('ReactJSXElementValidator', () => {
);
});

it('should update component stack after receiving next element', () => {
it('should update component stack after receiving next element', async () => {
function MyComp() {
return null;
}
Expand All @@ -192,9 +196,14 @@ describe('ReactJSXElementValidator', () => {
}

const container = document.createElement('div');
ReactDOM.render(<ParentComp warn={false} />, container);
const root = ReactDOMClient.createRoot(container);
await act(() => {
root.render(<ParentComp warn={false} />);
});
expect(() =>
ReactDOM.render(<ParentComp warn={true} />, container),
ReactDOM.flushSync(() => {
root.render(<ParentComp warn={true} />);
}),
).toErrorDev(
'Warning: Failed prop type: ' +
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
Expand Down

0 comments on commit f5e57a2

Please sign in to comment.