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
Copy file name to clipboardExpand all lines: docs/api.md
+40Lines changed: 40 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,7 @@ To get React Router working in your app, you need to render a router element at
29
29
-[`<StaticRouter>`](#staticrouter) should be used when server-rendering a website
30
30
-[`<NativeRouter>`](#nativerouter) should be used in [React Native](https://reactnative.dev/) apps
31
31
-[`<MemoryRouter>`](#memoryrouter) is useful in testing scenarios and as a reference implementation for the other routers
32
+
-[`<unstable_HistoryRouter>`](#unstable_historyrouter) is used with your own [`history`](https://github.com/remix-run/history) instance.
32
33
33
34
These routers provide the context that React Router needs to operate in a particular environment. Each one renders [a `<Router>`](#router) internally, which you may also do if you need more fine-grained control for some reason. But it is highly likely that one of the built-in routers is what you need.
34
35
@@ -233,6 +234,45 @@ describe("My app", () => {
233
234
});
234
235
```
235
236
237
+
### `<unstable_HistoryRouter>`
238
+
239
+
<details>
240
+
<summary>Type declaration</summary>
241
+
242
+
```tsx
243
+
declarefunction HistoryRouter(
244
+
props:HistoryRouterProps
245
+
):React.ReactElement;
246
+
247
+
interfaceHistoryRouterProps {
248
+
basename?:string;
249
+
children?:React.ReactNode;
250
+
history:History;
251
+
}
252
+
```
253
+
254
+
</details>
255
+
256
+
`<unstable_HistoryRouter>` takes an instance of the [`history`](https://github.com/remix-run/history) library as prop. This allows you to use that instance in non-React contexts or as a global variable.
<docs-warning>This API is currently prefixed as `unstable_` because you may unintentionally add two versions of the `history` library to your app, the one you have added to your package.json and whatever version React Router uses internally. If it is allowed by your tooling, it's recommended to not add `history` as a direct dependency and instead rely on the nested dependency from the `react-router` package. Once we have a mechanism to detect mis-matched versions, this API will remove its `unstable_` prefix.</docs-warning>
0 commit comments