Skip to content

Commit 0e95b5d

Browse files
authored
fix: support old act from react-dom
Fetching `act` from `react-dom/test-utils` is deprecated, but keep support for it for now.
1 parent a0566eb commit 0e95b5d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/test-utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
import { act } from "react";
1+
import * as React from 'react'
2+
import * as DeprecatedReactTestUtils from 'react-dom/test-utils'
3+
24
declare global {
35
var IS_REACT_ACT_ENVIRONMENT: boolean;
46
}
7+
8+
const act = typeof React.act === 'function' ? React.act : DeprecatedReactTestUtils.act
9+
510
type Item = {
611
callback: IntersectionObserverCallback;
712
elements: Set<Element>;

0 commit comments

Comments
 (0)