website/app/hooks/useMatch.ts
2024-09-25 09:26:35 +02:00

15 lines
321 B
TypeScript

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 };
};
}