MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / useRoute

Function useRoute

e2e/viewer/src/App.tsx:42–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40}
41
42const useRoute = () => {
43 const [hash, setHash] = useState(window.location.hash);
44 useEffect(() => {
45 const onChange = () => setHash(window.location.hash);
46 window.addEventListener("hashchange", onChange);
47 return () => window.removeEventListener("hashchange", onChange);
48 }, []);
49 const parts = hash.replace(/^#\/?/, "").split("/").filter(Boolean);
50 return parts.length >= 2 ? { target: parts[0], slug: parts[1] } : null;
51};
52
53export const App = () => {
54 const route = useRoute();

Callers 1

AppFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected