Skip to content

Commit

Permalink
Convert validateDOMNesting to createRoot (facebook#28098)
Browse files Browse the repository at this point in the history
ezpz
  • Loading branch information
rickhanlonii authored and AndyPengc12 committed Apr 15, 2024
1 parent 11bd519 commit 686d5bf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/react-dom/src/__tests__/validateDOMNesting-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

const React = require('react');
const ReactDOM = require('react-dom');
const ReactDOMClient = require('react-dom/client');

function expectWarnings(tags, warnings = [], withoutStack = 0) {
tags = [...tags];
Expand All @@ -28,8 +29,13 @@ function expectWarnings(tags, warnings = [], withoutStack = 0) {
element = <Tag>{element}</Tag>;
}

const root = ReactDOMClient.createRoot(container);
if (warnings.length) {
expect(() => ReactDOM.render(element, container)).toErrorDev(warnings, {
expect(() => {
ReactDOM.flushSync(() => {
root.render(element);
});
}).toErrorDev(warnings, {
withoutStack,
});
}
Expand Down

0 comments on commit 686d5bf

Please sign in to comment.