File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,16 @@ import ReactDOMClient from 'react-dom/client'
66
77const { debug, getElementLocatorSelectors } = utils
88
9- const activeActs = new Set < string > ( )
9+ let activeActs = 0
1010
1111function setActEnvironment ( env : boolean | undefined ) : void {
1212 ( globalThis as any ) . IS_REACT_ACT_ENVIRONMENT = env
1313}
1414
15+ function updateActEnvironment ( ) : void {
16+ setActEnvironment ( activeActs > 0 )
17+ }
18+
1519// @ts -expect-error unstable_act is not typed, but exported
1620const _act = React . act || React . unstable_act
1721
@@ -21,17 +25,14 @@ const _act = React.act || React.unstable_act
2125const act = typeof _act !== 'function'
2226 ? async ( cb : ( ) => unknown ) => { await cb ( ) }
2327 : async ( cb : ( ) => unknown ) => {
24- setActEnvironment ( true )
25- const actId = crypto . randomUUID ( )
26- activeActs . add ( actId )
28+ activeActs ++
29+ updateActEnvironment ( )
2730 try {
2831 await _act ( cb )
2932 }
3033 finally {
31- activeActs . delete ( actId )
32- if ( ! activeActs . size ) {
33- setActEnvironment ( false )
34- }
34+ activeActs --
35+ updateActEnvironment ( )
3536 }
3637 }
3738
You can’t perform that action at this time.
0 commit comments