Files
spacedrive/interface/hooks/useZodRouteParams.ts
Brendan Allan 936e016000 Replace locations.getExplorerData with search.paths (#812)
* retire locations.getExplorerData from interface

* regen core.ts

* replace tags.getExplorerData with search.objects

* types out the wazooo

* better optional halding

* ternary-ify

---------

Co-authored-by: Jamie Pine <ijamespine@me.com>
2023-05-16 08:43:59 +00:00

11 lines
347 B
TypeScript

import { useMemo } from 'react';
import { useParams } from 'react-router';
import { z } from 'zod';
export function useZodRouteParams<Z extends z.ZodType<Record<string, any>>>(schema: Z): z.infer<Z> {
// eslint-disable-next-line no-restricted-syntax
const params = useParams();
return useMemo(() => schema.parse(params), [params, schema]);
}