refactor: flatten routes

This commit is contained in:
Andrea
2024-09-25 09:26:35 +02:00
parent e14a7ffb3d
commit 888f6c3b01
5 changed files with 3 additions and 3 deletions

14
app/hooks/useMatch.ts Normal file
View File

@@ -0,0 +1,14 @@
import { useMatches } from "@remix-run/react";
export function useMatch() {
const matches = useMatches();
const { handle, ...rest } = matches[matches.length - 1];
if (handle == null) {
throw new Error("Bruh");
}
return { handle, ...rest } as unknown as {
handle: { to: string; text: string };
};
}