mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-20 06:28:14 -04:00
* zod-powered search params * fix ci * fix context menu * fix the *other* context menu --------- Co-authored-by: Utku Bakir <74243531+utkubakir@users.noreply.github.com>
11 lines
335 B
TypeScript
11 lines
335 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) {
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
const params = useParams();
|
|
|
|
return useMemo(() => schema.parse(params), [params, schema]);
|
|
}
|