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
type RouteHandle = { foo?: string }
interface FooRoute extends Omit<RouteObject, 'children'> {
handle?: RouteHandle
children?: FooRoute[]
};
const myRoutes: FooRoute[] = [
{
path: '/home',
element: <h1>Home</h1>,
handle: { foo: 'bar' }
},
{
path: '/anotherPage',
element: <h1>Another page</h1>,
handle: { foo: 'somethingElse' }
},
]
// 1. The type of the attribute "index" is incompatible. Cannot assign type "true" to type "false"
const router = createBrowserRouter(routes)
// 2. I defined RouteHandle this way, but there is no type inference when using useMatches
export declare function useMatches(): {
id: string;
pathname: string;
params: Params<string>;
data: unknown;
handle: unknown; // why unknown ?
}[];
const matches= useMatches()
const handle = useMatches().at(-1)?.handle as Handle // we need to cast it to get at them
Expected Behavior
Hopefully, I can define route type in this way
Actual Behavior
I cannot define route type in this way
The text was updated successfully, but these errors were encountered:
What version of React Router are you using?
6.4.3
Steps to Reproduce
Expected Behavior
Hopefully, I can define route type in this way
Actual Behavior
I cannot define route type in this way
The text was updated successfully, but these errors were encountered: