Skip to content

Commit 6a3c243

Browse files
committed
chore: generate markdown docs from jsdocs
1 parent 89f31ba commit 6a3c243

File tree

11 files changed

+395
-120
lines changed

11 files changed

+395
-120
lines changed

docs/api/components/Await.md

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ title: Await
44

55
# Await
66

7+
<!--
8+
⚠️ ⚠️ IMPORTANT ⚠️ ⚠️
9+
10+
Thank you for helping improve our documentation!
11+
12+
This file is auto-generated from the JSDoc comments in the source
13+
code, so please edit the JSDoc comments in the file below and this
14+
file will be re-generated once those changes are merged.
15+
16+
https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/components.tsx#L1264
17+
-->
18+
719
[MODES: framework, data]
820

921
## Summary
@@ -12,16 +24,16 @@ title: Await
1224

1325
Used to render promise values with automatic error handling.
1426

27+
**Note:** `<Await>` expects to be rendered inside of a `<React.Suspense>`
28+
1529
```tsx
1630
import { Await, useLoaderData } from "react-router";
1731

1832
export function loader() {
1933
// not awaited
2034
const reviews = getReviews();
2135
// awaited (blocks the transition)
22-
const book = await fetch("/api/book").then((res) =>
23-
res.json()
24-
);
36+
const book = await fetch("/api/book").then((res) => res.json());
2537
return { book, reviews };
2638
}
2739

@@ -47,14 +59,16 @@ function Book() {
4759
}
4860
```
4961

50-
`<Await>` expects to be rendered inside of a `<React.Suspense>`
62+
## Signature
63+
64+
```tsx
65+
function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>)
66+
```
5167

5268
## Props
5369

5470
### children
5571

56-
[modes: framework, data]
57-
5872
When using a function, the resolved value is provided as the parameter.
5973

6074
```tsx [2]
@@ -63,13 +77,13 @@ When using a function, the resolved value is provided as the parameter.
6377
</Await>
6478
```
6579

66-
When using React elements, [useAsyncValue](../hooks/useAsyncValue) will provide the
80+
When using React elements, [`useAsyncValue`](../hooks/useAsyncValue) will provide the
6781
resolved value:
6882

6983
```tsx [2]
7084
<Await resolve={reviewsPromise}>
7185
<Reviews />
72-
</Await>;
86+
</Await>
7387
7488
function Reviews() {
7589
const resolvedReviews = useAsyncValue();
@@ -79,8 +93,6 @@ function Reviews() {
7993

8094
### errorElement
8195

82-
[modes: framework, data]
83-
8496
The error element renders instead of the children when the promise rejects.
8597

8698
```tsx
@@ -92,7 +104,7 @@ The error element renders instead of the children when the promise rejects.
92104
</Await>
93105
```
94106

95-
To provide a more contextual error, you can use the [useAsyncError](../hooks/useAsyncError) in a
107+
To provide a more contextual error, you can use the [`useAsyncError`](../hooks/useAsyncError) in a
96108
child component
97109

98110
```tsx
@@ -101,7 +113,7 @@ child component
101113
resolve={reviewsPromise}
102114
>
103115
<Reviews />
104-
</Await>;
116+
</Await>
105117
106118
function ReviewsError() {
107119
const error = useAsyncError();
@@ -110,14 +122,12 @@ function ReviewsError() {
110122
```
111123

112124
If you do not provide an errorElement, the rejected value will bubble up to
113-
the nearest route-level ErrorBoundary and be accessible
114-
via [useRouteError](../hooks/useRouteError) hook.
125+
the nearest route-level `ErrorBoundary` and be accessible via the
126+
[`useRouteError`](../hooks/useRouteError) hook.
115127

116128
### resolve
117129

118-
[modes: framework, data]
119-
120-
Takes a promise returned from a [LoaderFunction](https://api.reactrouter.com/v7/types/react_router.LoaderFunction.html) value to be resolved and rendered.
130+
Takes a promise returned from a `loader` to be resolved and rendered.
121131

122132
```jsx
123133
import { useLoaderData, Await } from "react-router";
@@ -153,3 +163,4 @@ export default function Book() {
153163
);
154164
}
155165
```
166+

docs/api/components/Navigate.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,55 @@ title: Navigate
44

55
# Navigate
66

7+
<!--
8+
⚠️ ⚠️ IMPORTANT ⚠️ ⚠️
9+
10+
Thank you for helping improve our documentation!
11+
12+
This file is auto-generated from the JSDoc comments in the source
13+
code, so please edit the JSDoc comments in the file below and this
14+
file will be re-generated once those changes are merged.
15+
16+
https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/components.tsx#L645
17+
-->
18+
719
[MODES: framework, data, declarative]
820

921
## Summary
1022

1123
[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.Navigate.html)
1224

13-
A component-based version of [useNavigate](../hooks/useNavigate) to use in a [`React.Component
25+
A component-based version of [`useNavigate`](../hooks/useNavigate) to use in a [`React.Component
1426
Class`](https://reactjs.org/docs/react-component.html) where hooks are not
1527
able to be used.
1628

17-
It's recommended to avoid using this component in favor of [useNavigate](../hooks/useNavigate)
29+
It's recommended to avoid using this component in favor of [`useNavigate`](../hooks/useNavigate)
1830

1931
```tsx
2032
<Navigate to="/tasks" />
2133
```
2234

23-
## Props
35+
## Signature
2436

25-
### relative
37+
```tsx
38+
function Navigate({ to, replace, state, relative, }: NavigateProps): null
39+
```
2640

27-
[modes: framework, data, declarative]
41+
## Props
42+
43+
### to
2844

29-
_No documentation_
45+
The path to navigate to. This can be a string or an object
3046

3147
### replace
3248

33-
[modes: framework, data, declarative]
34-
35-
_No documentation_
49+
Whether to replace the current entry in the history stack
3650

3751
### state
3852

39-
[modes: framework, data, declarative]
53+
State to pass to the new location to store in [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state).
4054

41-
_No documentation_
42-
43-
### to
55+
### relative
4456

45-
[modes: framework, data, declarative]
57+
How to interpret relative routing in the `to` prop. See [`RelativeRoutingType`](https://api.reactrouter.com/v7/types/react_router.RelativeRoutingType.html).
4658

47-
_No documentation_

docs/api/components/Outlet.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ title: Outlet
44

55
# Outlet
66

7+
<!--
8+
⚠️ ⚠️ IMPORTANT ⚠️ ⚠️
9+
10+
Thank you for helping improve our documentation!
11+
12+
This file is auto-generated from the JSDoc comments in the source
13+
code, so please edit the JSDoc comments in the file below and this
14+
file will be re-generated once those changes are merged.
15+
16+
https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/components.tsx#L724
17+
-->
18+
719
[MODES: framework, data, declarative]
820

921
## Summary
@@ -25,16 +37,21 @@ export default function SomeParent() {
2537
}
2638
```
2739

40+
## Signature
41+
42+
```tsx
43+
function Outlet(props: OutletProps): React.ReactElement | null
44+
```
45+
2846
## Props
2947

3048
### context
3149

32-
[modes: framework, data, declarative]
33-
3450
Provides a context value to the element tree below the outlet. Use when the parent route needs to provide values to child routes.
3551

3652
```tsx
3753
<Outlet context={myContextValue} />
3854
```
3955

40-
Access the context with [useOutletContext](../hooks/useOutletContext).
56+
Access the context with [`useOutletContext`](../hooks/useOutletContext).
57+

docs/api/components/Route.md

Lines changed: 108 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,139 @@ title: Route
44

55
# Route
66

7+
<!--
8+
⚠️ ⚠️ IMPORTANT ⚠️ ⚠️
9+
10+
Thank you for helping improve our documentation!
11+
12+
This file is auto-generated from the JSDoc comments in the source
13+
code, so please edit the JSDoc comments in the file below and this
14+
file will be re-generated once those changes are merged.
15+
16+
https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/components.tsx#L920
17+
-->
18+
719
[MODES: framework, data, declarative]
820

921
## Summary
1022

1123
[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.Route.html)
1224

1325
Configures an element to render when a pattern matches the current location.
14-
It must be rendered within a [Routes](../components/Routes) element. Note that these routes
26+
It must be rendered within a [`Routes`](../components/Routes) element. Note that these routes
1527
do not participate in data loading, actions, code splitting, or any other
1628
route module features.
1729

30+
```tsx
31+
// Usually used in a declarative router
32+
function App() {
33+
return (
34+
<BrowserRouter>
35+
<Routes>
36+
<Route index element={<StepOne />} />
37+
<Route path="step-2" element={<StepTwo />} />
38+
<Route path="step-3" element={<StepThree />} />
39+
</Routes>
40+
</BrowserRouter>
41+
);
42+
}
43+
44+
// But can be used with a data router as well if you prefer the JSX notation
45+
const routes = createRoutesFromElements(
46+
<>
47+
<Route index loader={step1Loader} Component={StepOne} />
48+
<Route path="step-2" loader={step2Loader} Component={StepTwo} />
49+
<Route path="step-3" loader={step3Loader} Component={StepThree} />
50+
</>
51+
);
52+
53+
const router = createBrowserRouter(routes);
54+
55+
function App() {
56+
return <RouterProvider router={router} />;
57+
}
58+
```
59+
60+
## Signature
61+
62+
```tsx
63+
function Route(props: RouteProps): React.ReactElement | null
64+
```
65+
1866
## Props
1967

2068
### caseSensitive
2169

22-
[modes: framework, data, declarative]
70+
Whether the path should be case sensitive. Defaults to `false`.
2371

24-
Whether the path should be matched in a case-sensitive manner.
72+
### path
2573

26-
### children
74+
The path pattern to match. If unspecified or empty then this becomes a layout route.
2775

28-
[modes: framework, data, declarative]
76+
### id
2977

30-
_No documentation_
78+
The unique identifier for this route (for use with Data routers)
3179

32-
### Component
80+
### lazy
81+
82+
A function that returns a promise that resolves to the route object.
83+
Used for code-splitting routes.
84+
See [`lazy`](../../../start/data/route-object#lazy).
85+
86+
### loader
87+
88+
The route loader.
89+
See [`loader`](../../../start/data/route-object#loader).
90+
91+
### action
92+
93+
The route action.
94+
See [`action`](../../../start/data/route-object#action).
95+
96+
### shouldRevalidate
97+
98+
The route shouldRevalidate function.
99+
See [`shouldRevalidate`](../../../start/data/route-object#shouldRevalidate).
33100

34-
[modes: framework, data, declarative]
101+
### handle
35102

36-
_No documentation_
103+
The route handle.
104+
105+
### index
106+
107+
Whether or not this is an index route.
108+
109+
### children
110+
111+
Child Route components
37112

38113
### element
39114

40-
[modes: framework, data, declarative]
115+
The React element to render when this Route matches.
116+
Mutually exclusive with `Component`.
41117

42-
_No documentation_
118+
### hydrateFallbackElement
43119

44-
### path
120+
The React element to render while this router is loading data.
121+
Mutually exclusive with `HydrateFallback`.
122+
123+
### errorElement
124+
125+
The React element to render at this route if an error occurs.
126+
Mutually exclusive with `ErrorBoundary`.
127+
128+
### Component
129+
130+
The React Component to render when this route matches.
131+
Mutually exclusive with `element`.
132+
133+
### HydrateFallback
134+
135+
The React Component to render while this router is loading data.
136+
Mutually exclusive with `hydrateFallbackElement`.
137+
138+
### ErrorBoundary
45139

46-
[modes: framework, data, declarative]
140+
The React Component to render at this route if an error occurs.
141+
Mutually exclusive with `errorElement`.
47142

48-
The path to match against the current location.

0 commit comments

Comments
 (0)