T
TanStack2y ago
xenial-black

Get loader function context type for a route?

Is there a way to get the loader context type for a specific route for code split loaders? e.g. export const loader = (ctx: <context type for "/foo">) => ...
2 Replies
relaxed-coral
relaxed-coral2y ago
Yes, you can use the the FileRouteLoader api
export const loader = FileRouteLoader("/blog/$blogId")(async ({
context: { queryClient, fetchBlogIdOptions },
}) => {
queryClient.ensureQueryData(fetchBlogIdOptions);
});
export const loader = FileRouteLoader("/blog/$blogId")(async ({
context: { queryClient, fetchBlogIdOptions },
}) => {
queryClient.ensureQueryData(fetchBlogIdOptions);
});
xenial-black
xenial-blackOP2y ago
Perfect, thanks.

Did you find this page helpful?