From 686d5bf3ca7fc62911309b87c9828a0bc82102ba Mon Sep 17 00:00:00 2001 From: Ricky Date: Thu, 25 Jan 2024 22:30:56 -0500 Subject: [PATCH] Convert validateDOMNesting to createRoot (#28098) ezpz --- .../react-dom/src/__tests__/validateDOMNesting-test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/react-dom/src/__tests__/validateDOMNesting-test.js b/packages/react-dom/src/__tests__/validateDOMNesting-test.js index da7c7f3acb96a..ae97b98c2412a 100644 --- a/packages/react-dom/src/__tests__/validateDOMNesting-test.js +++ b/packages/react-dom/src/__tests__/validateDOMNesting-test.js @@ -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]; @@ -28,8 +29,13 @@ function expectWarnings(tags, warnings = [], withoutStack = 0) { element = {element}; } + const root = ReactDOMClient.createRoot(container); if (warnings.length) { - expect(() => ReactDOM.render(element, container)).toErrorDev(warnings, { + expect(() => { + ReactDOM.flushSync(() => { + root.render(element); + }); + }).toErrorDev(warnings, { withoutStack, }); }