diff --git a/app/utils.ts b/app/utils.ts index f6da6bd0..58a755bd 100644 --- a/app/utils.ts +++ b/app/utils.ts @@ -1,3 +1,4 @@ +import { type SerializeFrom } from '@remix-run/node' import { useMatches } from "@remix-run/react"; import { useMemo } from "react"; @@ -33,17 +34,18 @@ export function safeRedirect( * @param {string} id The route id * @returns {JSON|undefined} The router data or undefined if not found */ -export function useMatchesData( - id: string, -): Record | undefined { - const matchingRoutes = useMatches(); - const route = useMemo( - () => matchingRoutes.find((route) => route.id === id), - [matchingRoutes, id], - ); - return route?.data as Record; +export function useMatchesData | undefined>( + id: string, +): SerializeFrom { + const matchingRoutes = useMatches() + const route = useMemo( + () => matchingRoutes.find(route => route.id === id), + [matchingRoutes, id], + ) + return route?.data as SerializeFrom } + function isUser(user: unknown): user is User { return ( user != null &&