Files
Sybil-2/web/src/root-router.tsx

19 lines
530 B
TypeScript
Raw Normal View History

2026-02-14 00:22:19 -08:00
import { useEffect, useState } from "preact/hooks";
import App from "@/App";
import SearchRoutePage from "@/pages/search-route-page";
export function RootRouter() {
const [path, setPath] = useState(window.location.pathname);
useEffect(() => {
const onPopState = () => setPath(window.location.pathname);
window.addEventListener("popstate", onPopState);
return () => window.removeEventListener("popstate", onPopState);
}, []);
if (path === "/search") {
return <SearchRoutePage />;
}
return <App />;
}