跳到主要内容

<NativeRouter>

Type declaration
declare function NativeRouter(
props: NativeRouterProps
): React.ReactElement;

interface NativeRouterProps extends MemoryRouterProps {}

<NativeRouter> is the recommended interface for running React Router in a React Native app.

  • <NativeRouter initialEntries> defaults to ["/"] (a single entry at the root / URL)
  • <NativeRouter initialIndex> defaults to the last index of initialEntries
import * as React from "react";
import { NativeRouter } from "react-router-native";

function App() {
return (
<NativeRouter>
{/* The rest of your app goes here */}
</NativeRouter>
);
}