Skip to content

Commit 30b6458

Browse files
committed
docs: updates for create*Router functions
1 parent d47f0e7 commit 30b6458

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+929
-2128
lines changed

docs/components/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
title: Components
3-
order: 3
3+
order: 6
44
---

docs/components/routes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface RoutesProps {
1717
</Routes>;
1818
```
1919

20-
Note that if you're using a data router like [`<DataBrowserRouter>`][databrowserrouter] it is uncommon to use this component as it does not participate in data loading.
20+
<docs-info>If you're using a data router like [`createBrowserRouter`][createbrowserrouter] it is uncommon to use this component as it does not participate in data loading.</docs-info>
2121

2222
Whenever the location changes, `<Routes>` looks through all its child routes to find the best match and renders that branch of the UI. `<Route>` elements may be nested to indicate nested UI, which also correspond to nested URL paths. Parent routes render their child routes by rendering an [`<Outlet>`][outlet].
2323

@@ -37,4 +37,4 @@ Whenever the location changes, `<Routes>` looks through all its child routes to
3737
[location]: ../hook/location
3838
[outlet]: ./outlet
3939
[use-route]: ../hooks/use-routes
40-
[databrowserrouter]: ../routers/data-browser-router
40+
[createbrowserrouter]: ../routers/create-browser-router

docs/components/scroll-restoration.md

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,17 @@ This component will emulate the browser's scroll restoration on location changes
99

1010
You should only render one of these and it's recommended you render it in the root route of your app:
1111

12-
```tsx [5,12]
13-
import * as React from "react";
14-
import * as ReactDOM from "react-dom";
15-
import {
16-
DataBrowserRouter,
17-
ScrollRestoration,
18-
} from "react-router-dom";
19-
20-
function Root() {
12+
```tsx [1,7]
13+
import { ScrollRestoration } from "react-router-dom";
14+
15+
function RootRouteComponent() {
2116
return (
2217
<div>
2318
{/* ... */}
2419
<ScrollRestoration />
2520
</div>
2621
);
2722
}
28-
29-
ReactDOM.render(
30-
<DataBrowserRouter>
31-
<Route element={<Root />}>{/* child routes */}</Route>
32-
</DataBrowserRouter>,
33-
root
34-
);
3523
```
3624

3725
## `getKey`

docs/elements.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,63 +102,63 @@ And then there’s the `<dl>` lists:
102102
Normal code:
103103

104104
```tsx
105-
<DataBrowserRouter initialEntries={["/events/123"]}>
105+
<WhateverRouter initialEntries={["/events/123"]}>
106106
<Route path="/" element={<Root />} loader={rootLoader}>
107107
<Route
108108
path="events/:id"
109109
element={<Event />}
110110
loader={eventLoader}
111111
/>
112112
</Route>
113-
</DataBrowserRouter>
113+
</WhateverRouter>
114114
```
115115

116116
With multiple highlighted lines:
117117

118118
```tsx lines=[1-2,5]
119-
<DataBrowserRouter initialEntries={["/events/123"]}>
119+
<WhateverRouter initialEntries={["/events/123"]}>
120120
<Route path="/" element={<Root />} loader={rootLoader}>
121121
<Route
122122
path="events/:id"
123123
element={<Event />}
124124
loader={eventLoader}
125125
/>
126126
</Route>
127-
</DataBrowserRouter>
127+
</WhateverRouter>
128128
```
129129

130130
With a filename:
131131

132132
```tsx filename=src/main.jsx
133-
<DataBrowserRouter initialEntries={["/events/123"]}>
133+
<WhateverRouter initialEntries={["/events/123"]}>
134134
<Route path="/" element={<Root />} loader={rootLoader}>
135135
<Route
136136
path="events/:id"
137137
element={<Event />}
138138
loader={eventLoader}
139139
/>
140140
</Route>
141-
</DataBrowserRouter>
141+
</WhateverRouter>
142142
```
143143

144144
Bad code:
145145

146146
```tsx bad
147-
<DataBrowserRouter initialEntries={["/events/123"]}>
147+
<WhateverRouter initialEntries={["/events/123"]}>
148148
<Route path="/" element={<Root />} loader={rootLoader}>
149149
<Route
150150
path="events/:id"
151151
element={<Event />}
152152
loader={eventLoader}
153153
/>
154154
</Route>
155-
</DataBrowserRouter>
155+
</WhateverRouter>
156156
```
157157

158158
Bad code with highlighted lines and a filename:
159159

160160
```tsx filename=src/main.jsx bad lines=[2-5]
161-
<DataBrowserRouter initialEntries={["/events/123"]}>
161+
<WhateverRouter initialEntries={["/events/123"]}>
162162
<Routes>
163163
<Route path="/" element={<Root />} loader={rootLoader}>
164164
<Route
@@ -168,7 +168,7 @@ Bad code with highlighted lines and a filename:
168168
/>
169169
</Route>
170170
</Routes>
171-
</DataBrowserRouter>
171+
</WhateverRouter>
172172
```
173173

174174
Lines that overflow:

docs/fetch/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
title: Fetch Utilities
3-
order: 5
3+
order: 8
44
---

0 commit comments

Comments
 (0)