You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
version: 7.9.2 of react-router in an hydrogen project.
Hi 👋,
I have recently started playing with generated types for react-router and I have noticed the following.
In the following code
import type { Route } from './+types/....';
export const meta: Route.MetaFunction = ({ loaderData }) => ...
export async const loader: A = ...
export async const clientLoader: B = ...
It seems that the generated types expects that the argument LoaderData of the meta function is typed A | B.
I can only assume it has been made so it handles cases such as having only a clientLoader in a file.
My suggestion
I would expect loaderData to be typed
A only if there is a loader function
B only if there is a clientLoader function
A if both are defined.
It would avoid handling cases where property X is defined in the loader but not in the clientLoader, leading to extra code that is useless at runtime.
N.B
I am fairly new at using react-router extensively so forgive me if I missed part of the documentation or a use case I didn't think of.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context:
version: 7.9.2 of react-router in an hydrogen project.
Hi 👋,
I have recently started playing with generated types for react-router and I have noticed the following.
In the following code
It seems that the generated types expects that the argument LoaderData of the meta function is typed A | B.
I can only assume it has been made so it handles cases such as having only a clientLoader in a file.
My suggestion
I would expect loaderData to be typed
It would avoid handling cases where property X is defined in the loader but not in the clientLoader, leading to extra code that is useless at runtime.
N.B
I am fairly new at using react-router extensively so forgive me if I missed part of the documentation or a use case I didn't think of.
Beta Was this translation helpful? Give feedback.
All reactions