Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(remix-react): make RouteMatch a generic type #7333

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/stale-moles-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@remix-run/react": minor
---

Make `RouteMatch` a generic type

Now the `RouteMatch` type is a generic type that supports type inference. So just as you can do `useLoaderData<typeof loader>()`, now you can also do `RouteMatch<typeof loader>`.
4 changes: 2 additions & 2 deletions packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ function dedupe(array: any[]) {
}

// TODO: Can this be re-exported from RR?
export interface RouteMatch {
export interface RouteMatch<T = AppData> {
/**
* The id of the matched route
*/
Expand All @@ -994,7 +994,7 @@ export interface RouteMatch {
/**
* Any route data associated with the matched route
*/
data: any;
data: SerializeFrom<T>;
/**
* The exported `handle` object of the matched route.
*
Expand Down