mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-20 06:28:14 -04:00
* 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>
11 lines
347 B
TypeScript
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]);
|
|
}
|