本页还没有译文
本页 15 段还没译成Español,下面显示的是英文原文。useRoutes
还没翻译译自英文(reactrouter.com)本页 15 段都还没译
useRoutes
Framework Data Declarative
Summary
Hook version of <Routes> that uses objects instead of
components. These objects have the same properties as the component props.
The return value of useRoutes is either a valid React element you can use
to render the route tree, or null if nothing matched.
import { useRoutes } from "react-router";
function App() {
let element = useRoutes([
{
path: "/",
element: <Dashboard />,
children: [
{
path: "messages",
element: <DashboardMessages />,
},
{ path: "tasks", element: <DashboardTasks /> },
],
},
{ path: "team", element: <AboutPage /> },
]);
return element;
}Signature
function useRoutes(
routes: RouteObject[],
locationArg?: Partial<Location> | string,
): React.ReactElement | nullParams
routes
An array of RouteObjects that define the route hierarchy
locationArg
An optional Location object or pathname string to use instead of the current Location
Returns
A React element to render the matched route, or null if no routes matched
AI 翻译查看英文原文