Skip to content

Commit 7073795

Browse files
committed
Update docs for future flags
1 parent a0b53e3 commit 7073795

File tree

4 files changed

+138
-4
lines changed

4 files changed

+138
-4
lines changed

docs/router-components/browser-router.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ declare function BrowserRouter(
1515
interface BrowserRouterProps {
1616
basename?: string;
1717
children?: React.ReactNode;
18+
future?: FutureConfig;
1819
window?: Window;
1920
}
2021
```
@@ -23,8 +24,6 @@ interface BrowserRouterProps {
2324

2425
A `<BrowserRouter>` stores the current location in the browser's address bar using clean URLs and navigates using the browser's built-in history stack.
2526

26-
`<BrowserRouter window>` defaults to using the current [document's `defaultView`][defaultview], but it may also be used to track changes to another window's URL, in an `<iframe>`, for example.
27-
2827
```tsx
2928
import * as React from "react";
3029
import { createRoot } from "react-dom/client";
@@ -39,4 +38,39 @@ root.render(
3938
);
4039
```
4140

41+
## `basename`
42+
43+
Configure your application to run underneath a specific basename in the URL:
44+
45+
```jsx
46+
function App() {
47+
return (
48+
<BrowserRouter basename="/app">
49+
<Routes>
50+
<Route path="/" /> {/* 👈 Renders at /app/ */}
51+
</Routes>
52+
</BrowserRouter>
53+
);
54+
}
55+
```
56+
57+
## `future`
58+
59+
An optional set of [Future Flags][api-development-strategy] to enable. We recommend opting into newly released future flags sooner rather than later to ease your eventual migration to v7.
60+
61+
```jsx
62+
function App() {
63+
return (
64+
<BrowserRouter future={{ v7_startTransition: true }}>
65+
<Routes>{/*...*/}</Routes>
66+
</BrowserRouter>
67+
);
68+
}
69+
```
70+
71+
## `window`
72+
73+
`BrowserRouter` defaults to using the current [document's `defaultView`][defaultview], but it may also be used to track changes to another window's URL, in an `<iframe>`, for example.
74+
4275
[defaultview]: https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView
76+
[api-development-strategy]: ../guides/api-development-strategy

docs/router-components/hash-router.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ declare function HashRouter(
1515
interface HashRouterProps {
1616
basename?: string;
1717
children?: React.ReactNode;
18+
future?: FutureConfig;
1819
window?: Window;
1920
}
2021
```
@@ -23,8 +24,6 @@ interface HashRouterProps {
2324

2425
`<HashRouter>` is for use in web browsers when the URL should not (or cannot) be sent to the server for some reason. This may happen in some shared hosting scenarios where you do not have full control over the server. In these situations, `<HashRouter>` makes it possible to store the current location in the `hash` portion of the current URL, so it is never sent to the server.
2526

26-
`<HashRouter window>` defaults to using the current [document's `defaultView`][defaultview], but it may also be used to track changes to another window's URL, in an `<iframe>`, for example.
27-
2827
```tsx
2928
import * as React from "react";
3029
import * as ReactDOM from "react-dom";
@@ -40,4 +39,39 @@ ReactDOM.render(
4039

4140
<docs-warning>We strongly recommend you do not use `HashRouter` unless you absolutely have to.</docs-warning>
4241

42+
## `basename`
43+
44+
Configure your application to run underneath a specific basename in the URL:
45+
46+
```jsx
47+
function App() {
48+
return (
49+
<HashRouter basename="/app">
50+
<Routes>
51+
<Route path="/" /> {/* 👈 Renders at /#/app/ */}
52+
</Routes>
53+
</HashRouter>
54+
);
55+
}
56+
```
57+
58+
## `future`
59+
60+
An optional set of [Future Flags][api-development-strategy] to enable. We recommend opting into newly released future flags sooner rather than later to ease your eventual migration to v7.
61+
62+
```jsx
63+
function App() {
64+
return (
65+
<HashRouter future={{ v7_startTransition: true }}>
66+
<Routes>{/*...*/}</Routes>
67+
</HashRouter>
68+
);
69+
}
70+
```
71+
72+
## `window`
73+
74+
`HashRouter` defaults to using the current [document's `defaultView`][defaultview], but it may also be used to track changes to another window's URL, in an `<iframe>`, for example.
75+
4376
[defaultview]: https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView
77+
[api-development-strategy]: ../guides/api-development-strategy

docs/router-components/memory-router.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface MemoryRouterProps {
1717
children?: React.ReactNode;
1818
initialEntries?: InitialEntry[];
1919
initialIndex?: number;
20+
future?: FutureConfig;
2021
}
2122
```
2223

@@ -59,4 +60,36 @@ describe("My app", () => {
5960
});
6061
```
6162

63+
## `basename`
64+
65+
Configure your application to run underneath a specific basename in the URL:
66+
67+
```jsx
68+
function App() {
69+
return (
70+
<MemoryRouter basename="/app">
71+
<Routes>
72+
<Route path="/" /> {/* 👈 Renders at /app/ */}
73+
</Routes>
74+
</MemoryRouter>
75+
);
76+
}
77+
```
78+
79+
## `future`
80+
81+
An optional set of [Future Flags][api-development-strategy] to enable. We recommend opting into newly released future flags sooner rather than later to ease your eventual migration to v7.
82+
83+
```jsx
84+
function App() {
85+
return (
86+
<MemoryRouter future={{ v7_startTransition: true }}>
87+
<Routes>{/*...*/}</Routes>
88+
</MemoryRouter>
89+
);
90+
}
91+
```
92+
93+
[defaultview]: https://developer.mozilla.org/en-US/docs/Web/API/Document/defaultView
94+
[api-development-strategy]: ../guides/api-development-strategy
6295
[tests]: https://github.com/remix-run/react-router/tree/main/packages/react-router/__tests__

docs/routers/router-provider.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ new: true
55

66
# `<RouterProvider>`
77

8+
<details>
9+
<summary>Type declaration</summary>
10+
11+
```tsx
12+
declare function RouterProvider(
13+
props: RouterProviderProps
14+
): React.ReactElement;
15+
16+
interface RouterProviderProps {
17+
fallbackElement?: React.ReactNode;
18+
router: Router;
19+
future?: FutureConfig;
20+
}
21+
```
22+
23+
</details>
24+
825
All [data router][picking-a-router] objects are passed to this component to render your app and enable the rest of the data APIs.
926

1027
```jsx lines=[24]
@@ -49,4 +66,20 @@ If you are not server rendering your app, `createBrowserRouter` will initiate al
4966
/>
5067
```
5168

69+
## `future`
70+
71+
An optional set of [Future Flags][api-development-strategy] to enable. We recommend opting into newly released future flags sooner rather than later to ease your eventual migration to v7.
72+
73+
```jsx
74+
function App() {
75+
return (
76+
<RouterProvider
77+
router={router}
78+
future={{ v7_startTransition: true }}
79+
/>
80+
);
81+
}
82+
```
83+
5284
[picking-a-router]: ./picking-a-router
85+
[api-development-strategy]: ../guides/api-development-strategy

0 commit comments

Comments
 (0)