donavon / superjson-remix

MIT License
83 stars 4 forks source link

Also wrap `useMatches` #1

Open nicholaschiang opened 2 years ago

nicholaschiang commented 2 years ago

Similarly to useLoaderData, I'm guessing you'll also have to wrap useMatches with Blitz.js's superjson package.

nicholaschiang commented 2 years ago

This is what I'm using right now:

export function useMatches(): ReturnType<typeof useRemixMatches> {
  const matches = useRemixMatches();
  return matches.map(({ data, ...rest }) => ({
    ...rest,
    data: data ? parse(data as SuperJSONResult) : data,
  }));
}
TheRealFlyingCoder commented 2 years ago

Similarly this is necessary on the Remix Handle function

export const handle = withSuperJson((matches: MatchesProps) => '');