Matches the given routes to a location and returns the match data.
import { matchRoutes } from "react-router";
let routes = [{
path: "/",
Component: Root,
children: [{
path: "dashboard",
Component: Dashboard,
}]
}];
matchRoutes(routes, "/dashboard"); // [rootMatch, dashboardMatch]
function matchRoutes<
RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject,
>(
routes: RouteObjectType[],
locationArg: Partial<Location> | string,
basename = "/",
): AgnosticRouteMatch<string, RouteObjectType>[] | null
The array of route objects to match against.
The location to match against, either a string path or a partial Location
object
Optional base path to strip from the location before matching. Defaults to /
.
An array of matched routes, or null
if no matches were found.