diff --git a/extensions/plugin-basic-ui/src/components/AppScreen.tsx b/extensions/plugin-basic-ui/src/components/AppScreen.tsx index 6940bf124..93b49b6f6 100644 --- a/extensions/plugin-basic-ui/src/components/AppScreen.tsx +++ b/extensions/plugin-basic-ui/src/components/AppScreen.tsx @@ -7,6 +7,7 @@ import type { GlobalVars } from "../basicUIPlugin.css"; import { globalVars } from "../basicUIPlugin.css"; import { useLazy, + useMounted, useNullableActivity, useStyleEffectHide, useStyleEffectOffset, @@ -49,6 +50,7 @@ const AppScreen: React.FC = ({ }) => { const globalOptions = useGlobalOptions(); const activity = useNullableActivity(); + const mounted = useMounted(); const { pop } = useActions(); @@ -182,8 +184,10 @@ const AppScreen: React.FC = ({ }), )} data-stackflow-component-name="AppScreen" - data-stackflow-activity-id={activity?.id} - data-stackflow-activity-is-active={activity?.isActive} + data-stackflow-activity-id={mounted ? activity?.id : undefined} + data-stackflow-activity-is-active={ + mounted ? activity?.isActive : undefined + } > {activityEnterStyle !== "slideInLeft" && (
diff --git a/extensions/plugin-basic-ui/src/hooks/index.ts b/extensions/plugin-basic-ui/src/hooks/index.ts index 626963b2b..ec1874e93 100644 --- a/extensions/plugin-basic-ui/src/hooks/index.ts +++ b/extensions/plugin-basic-ui/src/hooks/index.ts @@ -1,5 +1,6 @@ export * from "./useLazy"; export * from "./useMaxWidth"; +export * from "./useMounted"; export * from "./useNullableActivity"; export * from "./useStyleEffect"; export * from "./useStyleEffectHide"; diff --git a/extensions/plugin-basic-ui/src/hooks/useMounted.ts b/extensions/plugin-basic-ui/src/hooks/useMounted.ts new file mode 100644 index 000000000..fca57ad33 --- /dev/null +++ b/extensions/plugin-basic-ui/src/hooks/useMounted.ts @@ -0,0 +1,11 @@ +import { useEffect, useReducer, useState } from "react"; + +export function useMounted() { + const [mounted, mount] = useReducer(() => true, false); + + useEffect(() => { + mount(); + }, []); + + return mounted; +}