@@ -5,9 +5,10 @@ import {
55 Queries ,
66 type RenderOptions ,
77 type RenderResult ,
8- } from '@testing-library/react'
8+ } from '@testing-library/react/pure.js '
99import React from 'react'
10- import { SyncQueries } from './syncQueries.js'
10+ import { SyncQueries } from './renderStream/syncQueries.js'
11+ import { withDisabledActEnvironment } from './withDisabledActEnvironment.js'
1112
1213// Ideally we'd just use a WeakMap where containers are keys and roots are values.
1314// We use two variables so that we can bail out in constant time when we render with a new container (most common use case)
@@ -32,8 +33,6 @@ function renderRoot(
3233 root : ReturnType < typeof createConcurrentRoot >
3334 } ,
3435) : RenderResult < Queries , any , any > {
35- // @ts -expect-error this is not defined anywhere
36- globalThis . IS_REACT_ACT_ENVIRONMENT = false
3736 root . render (
3837 WrapperComponent ? React . createElement ( WrapperComponent , null , ui ) : ui ,
3938 )
@@ -164,14 +163,16 @@ export function renderWithoutAct(
164163}
165164
166165function createConcurrentRoot ( container : ReactDOMClient . Container ) {
167- const root = ReactDOMClient . createRoot ( container )
166+ const root = withDisabledActEnvironment ( ( ) =>
167+ ReactDOMClient . createRoot ( container ) ,
168+ )
168169
169170 return {
170171 render ( element : React . ReactNode ) {
171- root . render ( element )
172+ withDisabledActEnvironment ( ( ) => root . render ( element ) )
172173 } ,
173174 unmount ( ) {
174- root . unmount ( )
175+ withDisabledActEnvironment ( ( ) => root . unmount ( ) )
175176 } ,
176177 }
177178}
0 commit comments