File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { act } from "react-dom/test-utils" ;
2-
2+ declare global {
3+ // biome-ignore lint/style/noVar: Needs to be `var`, not `let` or `const`, for typing to work
4+ var IS_REACT_ACT_ENVIRONMENT : boolean ;
5+ }
36type Item = {
47 callback : IntersectionObserverCallback ;
58 elements : Set < Element > ;
@@ -93,6 +96,10 @@ export function resetIntersectionMocking() {
9396 observers . clear ( ) ;
9497}
9598
99+ function getIsReactActEnvironment ( ) {
100+ return Boolean ( global . IS_REACT_ACT_ENVIRONMENT ) ;
101+ }
102+
96103function triggerIntersection (
97104 elements : Element [ ] ,
98105 trigger : boolean | number ,
@@ -148,7 +155,8 @@ function triggerIntersection(
148155 }
149156
150157 // Trigger the IntersectionObserver callback with all the entries
151- if ( act ) act ( ( ) => item . callback ( entries , observer ) ) ;
158+ if ( act && getIsReactActEnvironment ( ) )
159+ act ( ( ) => item . callback ( entries , observer ) ) ;
152160 else item . callback ( entries , observer ) ;
153161}
154162/**
You can’t perform that action at this time.
0 commit comments