22
33// This test harness mounts each test app as a separate root to test multi-root applications.
44
5+ import semver from 'semver' ;
6+
57import { createElement } from 'react' ;
68import { createRoot } from 'react-dom/client' ;
7- import { render , unmountComponentAtNode } from 'react-dom' ;
9+
810import DeeplyNestedComponents from './DeeplyNestedComponents' ;
911import Iframe from './Iframe' ;
1012import EditableProps from './EditableProps' ;
@@ -67,6 +69,8 @@ function mountStrictApp(App) {
6769}
6870
6971function mountLegacyApp ( App : ( ) = > React$Node ) {
72+ const { render, unmountComponentAtNode} = require ( 'react-dom' ) ;
73+
7074 function LegacyRender ( ) {
7175 return createElement ( App ) ;
7276 }
@@ -78,6 +82,10 @@ function mountLegacyApp(App: () => React$Node) {
7882 unmountFunctions . push ( ( ) => unmountComponentAtNode ( container ) ) ;
7983}
8084
85+ const shouldRenderLegacy = semver . lte (
86+ process . env . E2E_APP_REACT_VERSION ,
87+ '18.2.0' ,
88+ ) ;
8189function mountTestApp ( ) {
8290 mountStrictApp ( ToDoList ) ;
8391 mountApp ( InspectableElements ) ;
@@ -90,7 +98,10 @@ function mountTestApp() {
9098 mountApp ( SuspenseTree ) ;
9199 mountApp ( DeeplyNestedComponents ) ;
92100 mountApp ( Iframe ) ;
93- mountLegacyApp ( PartiallyStrictApp ) ;
101+
102+ if ( shouldRenderLegacy ) {
103+ mountLegacyApp ( PartiallyStrictApp ) ;
104+ }
94105}
95106
96107function unmountTestApp ( ) {
0 commit comments