From 0e95b5d8ed255c5809db622cc4c3181d7cce4d74 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt <3764345+thebuilder@users.noreply.github.com> Date: Fri, 3 May 2024 22:58:58 +0200 Subject: [PATCH 1/3] fix: support old act from react-dom Fetching `act` from `react-dom/test-utils` is deprecated, but keep support for it for now. --- src/test-utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test-utils.ts b/src/test-utils.ts index 0efc234e..389f8136 100644 --- a/src/test-utils.ts +++ b/src/test-utils.ts @@ -1,7 +1,12 @@ -import { act } from "react"; +import * as React from 'react' +import * as DeprecatedReactTestUtils from 'react-dom/test-utils' + declare global { var IS_REACT_ACT_ENVIRONMENT: boolean; } + +const act = typeof React.act === 'function' ? React.act : DeprecatedReactTestUtils.act + type Item = { callback: IntersectionObserverCallback; elements: Set; From 5415441b40182c4a07c4d803595548bb9718fb95 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt <3764345+thebuilder@users.noreply.github.com> Date: Fri, 3 May 2024 23:00:30 +0200 Subject: [PATCH 2/3] Update test-utils.ts add semi colons --- src/test-utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test-utils.ts b/src/test-utils.ts index 389f8136..d84d5be1 100644 --- a/src/test-utils.ts +++ b/src/test-utils.ts @@ -1,11 +1,11 @@ -import * as React from 'react' -import * as DeprecatedReactTestUtils from 'react-dom/test-utils' +import * as React from 'react'; +import * as DeprecatedReactTestUtils from 'react-dom/test-utils'; declare global { var IS_REACT_ACT_ENVIRONMENT: boolean; } -const act = typeof React.act === 'function' ? React.act : DeprecatedReactTestUtils.act +const act = typeof React.act === 'function' ? React.act : DeprecatedReactTestUtils.act; type Item = { callback: IntersectionObserverCallback; From 0dbb29c1e6ec5243c2ed8816eb42d42d5cb48f36 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt <3764345+thebuilder@users.noreply.github.com> Date: Fri, 3 May 2024 21:09:20 +0000 Subject: [PATCH 3/3] chore: apply linting --- src/test-utils.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test-utils.ts b/src/test-utils.ts index d84d5be1..1f0df2cd 100644 --- a/src/test-utils.ts +++ b/src/test-utils.ts @@ -1,11 +1,12 @@ -import * as React from 'react'; -import * as DeprecatedReactTestUtils from 'react-dom/test-utils'; +import * as React from "react"; +import * as DeprecatedReactTestUtils from "react-dom/test-utils"; declare global { var IS_REACT_ACT_ENVIRONMENT: boolean; } -const act = typeof React.act === 'function' ? React.act : DeprecatedReactTestUtils.act; +const act = + typeof React.act === "function" ? React.act : DeprecatedReactTestUtils.act; type Item = { callback: IntersectionObserverCallback;