@@ -5,9 +5,10 @@ import {
5
5
Queries ,
6
6
type RenderOptions ,
7
7
type RenderResult ,
8
- } from '@testing-library/react'
8
+ } from '@testing-library/react/pure.js '
9
9
import React from 'react'
10
- import { SyncQueries } from './syncQueries.js'
10
+ import { SyncQueries } from './renderStream/syncQueries.js'
11
+ import { withDisabledActEnvironment } from './withDisabledActEnvironment.js'
11
12
12
13
// Ideally we'd just use a WeakMap where containers are keys and roots are values.
13
14
// 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(
32
33
root : ReturnType < typeof createConcurrentRoot >
33
34
} ,
34
35
) : RenderResult < Queries , any , any > {
35
- // @ts -expect-error this is not defined anywhere
36
- globalThis . IS_REACT_ACT_ENVIRONMENT = false
37
36
root . render (
38
37
WrapperComponent ? React . createElement ( WrapperComponent , null , ui ) : ui ,
39
38
)
@@ -164,14 +163,16 @@ export function renderWithoutAct(
164
163
}
165
164
166
165
function createConcurrentRoot ( container : ReactDOMClient . Container ) {
167
- const root = ReactDOMClient . createRoot ( container )
166
+ const root = withDisabledActEnvironment ( ( ) =>
167
+ ReactDOMClient . createRoot ( container ) ,
168
+ )
168
169
169
170
return {
170
171
render ( element : React . ReactNode ) {
171
- root . render ( element )
172
+ withDisabledActEnvironment ( ( ) => root . render ( element ) )
172
173
} ,
173
174
unmount ( ) {
174
- root . unmount ( )
175
+ withDisabledActEnvironment ( ( ) => root . unmount ( ) )
175
176
} ,
176
177
}
177
178
}
0 commit comments