Generic DataFunctionArgs for Params typing #7893
sdriffill-tm
started this conversation in
Proposals
Replies: 1 comment
-
P.S. Have been able to use the following as a workaround for the meantime: import type { DataFunctionArgs as RemixDataFunctionArgs } from '@remix-run/node';
import type { Params } from '@remix-run/react';
export type DataFunctionArgs<Key extends string = string> = Omit<
RemixDataFunctionArgs,
'params'
> & {
params: Params<Key>;
};
export type LoaderFunctionArgs<Key extends string = string> =
DataFunctionArgs<Key>;
export type ActionFunctionArgs<Key extends string = string> =
DataFunctionArgs<Key>; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The hook
useParams
is generic such that I can specify the params I'm expecting to be available for my route e.g.It would be great if
LoaderFunctionArgs
andActionFunctionArgs
were similarly generic so that I can set this expectation consistently across my loader, action and route. E.g.It would be even more awesome if remix could inspect the dynamic segments for the current route and determine this type for me, but I would definitely assume that's just completely out of the question! The proposal alone would be a really useful enhancement.
Beta Was this translation helpful? Give feedback.
All reactions