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 validateDOMNesting to createRoot #28098

Merged
merged 1 commit into from
Jan 26, 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
Convert validateDOMNesting to createRoot
  • Loading branch information
rickhanlonii committed Jan 25, 2024
commit c5e9e9d83acdf5d574eb0f66b4afcc7c9adb680a
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