Files
money/apps/expo/app/[...route].tsx
2025-11-15 18:49:17 -05:00

31 lines
827 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useLocalSearchParams } from "expo-router";
import { Text } from "react-native";
import { App } from "@money/ui";
import { useEffect, useState } from "react";
export default function Page() {
const { route: initalRoute } = useLocalSearchParams<{ route: string[] }>();
const [route, setRoute] = useState(initalRoute[0]!);
// detect back/forward
useEffect(() => {
const handler = () => {
const newRoute = window.location.pathname.slice(1);
// call your apps page change logic
setRoute(newRoute);
};
window.addEventListener("popstate", handler);
return () => window.removeEventListener("popstate", handler);
}, []);
return (
<App
page={route as any}
onPageChange={(page) => {
window.history.pushState({}, "", "/" + page);
}}
/>
);
}