Skip to content

Commit eebe0c6

Browse files
committed
feat: add version check
1 parent a488fe9 commit eebe0c6

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

integrations/react/src/stable/stackflow.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import { useActions } from "./useActions";
2626
import type { UseStepActionsOutputType } from "./useStepActions";
2727
import { useStepActions } from "./useStepActions";
2828

29+
import { version } from "react";
30+
2931
function parseActionOptions(options?: { animate?: boolean }) {
3032
if (!options) {
3133
return { skipActiveState: false };
@@ -145,9 +147,18 @@ export function stackflow<T extends BaseActivities>(
145147
...(options.plugins ?? [])
146148
.flat(Number.POSITIVE_INFINITY as 0)
147149
.map((p) => p as StackflowReactPlugin),
148-
lazyActivityPlugin(activityComponentMap),
149150
];
150151

152+
const majorReactVersion = Number.parseInt(version);
153+
154+
/**
155+
* TODO: This plugin depends on internal APIs of React.
156+
* A proper solution (e.g. Suspense integration) should be implemented in the next major version.
157+
*/
158+
if (majorReactVersion >= 18 && majorReactVersion <= 19) {
159+
plugins.push(lazyActivityPlugin(activityComponentMap));
160+
}
161+
151162
const enoughPastTime = () =>
152163
new Date().getTime() - options.transitionDuration * 2;
153164

0 commit comments

Comments
 (0)