Skip to content

Commit 12496f0

Browse files
committed
feat: 兼容react19
1 parent 2ffdc4e commit 12496f0

3 files changed

Lines changed: 16 additions & 19 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.0.8",
2+
"version": "1.0.9",
33
"license": "MIT",
44
"main": "dist/cjs/index.js",
55
"module": "dist/esm/index.mjs",

src/Activity.tsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use client";
12
import React, { Suspense } from "react";
23
import { Repeater } from "./Repeater";
34
import { canUseDOM } from "./canUseDOM";
@@ -7,30 +8,26 @@ import type { IProps } from "./type";
78
const isSupportStableActivity = "Activity" in React;
89
const isBrowser = canUseDOM();
910

10-
const NativeActivity = (
11-
isSupportStableActivity
12-
// @ts-ignore
13-
? React.Activity as ExoticComponent<IProps>
14-
: "unstable_Activity" in React
15-
// @ts-ignore
16-
? React.unstable_Activity as ExoticComponent<IProps>
17-
: null
18-
);
11+
const NativeActivity = isSupportStableActivity
12+
? // @ts-expect-error React.Activity is not yet fully typed in @types/react
13+
(React.Activity as ExoticComponent<IProps>)
14+
: "unstable_Activity" in React
15+
? (React.unstable_Activity as ExoticComponent<IProps>)
16+
: null;
1917

20-
21-
if(isBrowser && isSupportStableActivity) {
18+
if (isBrowser && isSupportStableActivity) {
2219
console.warn(
2320
navigator.language === "zh-CN"
24-
? '检测到您使用的react版本已经原生支持了Activity,我们 建议您迁移至原生Activity。'
25-
: 'It is detected that the react version you are using already supports Activity natively. We recommend that you migrate to native Activity.'
26-
)
21+
? "检测到您使用的react版本已经原生支持了Activity,我们 建议您迁移至原生Activity。"
22+
: "It is detected that the react version you are using already supports Activity natively. We recommend that you migrate to native Activity.",
23+
);
2724
}
2825

2926
/**
30-
*
27+
*
3128
* @param {IProps} props
3229
* @description This is a component that keeps its state while hiding it
33-
* @example
30+
* @example
3431
* when visible
3532
* <Activity mode="visible">
3633
* <Child />

src/Repeater.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export const Repeater: FC<IProps> = (props) => {
1010
const promiseRef = useRef<Promise<void> | null>(null);
1111
const resolveRef = useRef<(() => void) | null>(null);
1212
// methods
13-
const resolvePromise = (ignoreMode?: boolean) => {
13+
const resolvePromise = (ignore?: boolean) => {
1414
if (
15-
(ignoreMode || mode === "visible") &&
15+
(ignore || mode === "visible") &&
1616
typeof resolveRef.current === "function"
1717
) {
1818
resolveRef.current();

0 commit comments

Comments
 (0)