mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-08 12:54:05 +00:00
- Revert useExplorerSearchParams removal - Move schemas to a rout-schemas file - Formatting
10 lines
335 B
TypeScript
10 lines
335 B
TypeScript
import { useMemo } from 'react';
|
|
import { useParams } from 'react-router';
|
|
import type { z } from 'zod';
|
|
|
|
export function useZodRouteParams<Z extends z.AnyZodObject>(schema: Z): z.infer<Z> {
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
const params = useParams();
|
|
return useMemo(() => schema.parse(params), [params, schema]);
|
|
}
|