Skip to content

Commit 1b68981

Browse files
committed
chore: generate markdown docs from jsdocs
1 parent a71a1da commit 1b68981

13 files changed

+367
-100
lines changed

docs/api/data-routers/createBrowserRouter.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ application's data needs.
7373

7474
The `dataStrategy` function should return a key/value-object of
7575
`routeId` -> [`DataStrategyResult`](https://api.reactrouter.com/v7/interfaces/react_router.DataStrategyResult.html) and should include entries for any
76-
routes where a handler was executed. A [`DataStrategyResult`](https://api.reactrouter.com/v7/interfaces/react_router.DataStrategyResult.html) indicates
76+
routes where a handler was executed. A `DataStrategyResult` indicates
7777
if the handler was successful or not based on the `DataStrategyResult.type`
7878
field. If the returned `DataStrategyResult.result` is a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response),
7979
React Router will unwrap it for you (via [`res.json`](https://developer.mozilla.org/en-US/docs/Web/API/Response/json)
@@ -266,16 +266,15 @@ server-rendered app. But in advanced use-cases (such as Framework Mode's
266266
[`clientLoader`](../../start/framework/route-module#clientLoader)), you may
267267
want to include `loaderData` for only some routes that were loaded/rendered
268268
on the server. This allows you to hydrate _some_ of the routes (such as the
269-
app layout/shell) while showing a ``HydrateFallback``
269+
app layout/shell) while showing a `HydrateFallback`
270270
component and running the [`loader`](../../start/data/route-object#loader)s
271271
for other routes during hydration.
272272

273273
A route [`loader`](../../start/data/route-object#loader) will run during
274274
hydration in two scenarios:
275275

276276
1. No hydration data is provided
277-
In these cases the ``HydrateFallback``
278-
component will render on initial hydration
277+
In these cases the `HydrateFallback` component will render on initial hydration
279278
2. The `loader.hydrate` property is set to `true`
280279
This allows you to run the [`loader`](../../start/data/route-object#loader)
281280
even if you did not render a fallback on initial hydration (i.e., to
@@ -347,7 +346,7 @@ user visited.
347346

348347
`patchRoutesOnNavigation` will be called anytime React Router is unable to
349348
match a `path`. The arguments include the `path`, any partial
350-
``matches``, and a `patch` function you can call to patch
349+
`matches`, and a `patch` function you can call to patch
351350
new routes into the tree at a specific location. This method is executed
352351
during the `loading` portion of the navigation for `GET` requests and during
353352
the `submitting` portion of the navigation for non-`GET` requests.
@@ -450,7 +449,7 @@ the `submitting` portion of the navigation for non-`GET` requests.
450449
**Co-locating route discovery with route definition**
451450

452451
If you don't wish to perform your own pseudo-matching, you can leverage
453-
the partial ``matches`` array and the [`handle`](../../start/data/route-object#handle)
452+
the partial `matches` array and the [`handle`](../../start/data/route-object#handle)
454453
field on a route to keep the children definitions co-located:
455454

456455
```tsx

docs/api/data-routers/createHashRouter.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,15 @@ server-rendered app. But in advanced use-cases (such as Framework Mode's
7979
[`clientLoader`](../../start/framework/route-module#clientLoader)), you may
8080
want to include `loaderData` for only some routes that were loaded/rendered
8181
on the server. This allows you to hydrate _some_ of the routes (such as the
82-
app layout/shell) while showing a ``HydrateFallback``
82+
app layout/shell) while showing a `HydrateFallback`
8383
component and running the [`loader`](../../start/data/route-object#loader)s
8484
for other routes during hydration.
8585

8686
A route [`loader`](../../start/data/route-object#loader) will run during
8787
hydration in two scenarios:
8888

8989
1. No hydration data is provided
90-
In these cases the ``HydrateFallback``
91-
component will render on initial hydration
90+
In these cases the `HydrateFallback` component will render on initial hydration
9291
2. The `loader.hydrate` property is set to `true`
9392
This allows you to run the [`loader`](../../start/data/route-object#loader)
9493
even if you did not render a fallback on initial hydration (i.e., to
@@ -150,7 +149,7 @@ application's data needs.
150149

151150
The `dataStrategy` function should return a key/value-object of
152151
`routeId` -> [`DataStrategyResult`](https://api.reactrouter.com/v7/interfaces/react_router.DataStrategyResult.html) and should include entries for any
153-
routes where a handler was executed. A [`DataStrategyResult`](https://api.reactrouter.com/v7/interfaces/react_router.DataStrategyResult.html) indicates
152+
routes where a handler was executed. A `DataStrategyResult` indicates
154153
if the handler was successful or not based on the `DataStrategyResult.type`
155154
field. If the returned `DataStrategyResult.result` is a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response),
156155
React Router will unwrap it for you (via [`res.json`](https://developer.mozilla.org/en-US/docs/Web/API/Response/json)
@@ -346,7 +345,7 @@ user visited.
346345
347346
`patchRoutesOnNavigation` will be called anytime React Router is unable to
348347
match a `path`. The arguments include the `path`, any partial
349-
``matches``, and a `patch` function you can call to patch
348+
`matches`, and a `patch` function you can call to patch
350349
new routes into the tree at a specific location. This method is executed
351350
during the `loading` portion of the navigation for `GET` requests and during
352351
the `submitting` portion of the navigation for non-`GET` requests.
@@ -449,7 +448,7 @@ the `submitting` portion of the navigation for non-`GET` requests.
449448
**Co-locating route discovery with route definition**
450449
451450
If you don't wish to perform your own pseudo-matching, you can leverage
452-
the partial ``matches`` array and the [`handle`](../../start/data/route-object#handle)
451+
the partial `matches` array and the [`handle`](../../start/data/route-object#handle)
453452
field on a route to keep the children definitions co-located:
454453
455454
```tsx
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
title: RouterContextProvider
3+
unstable: true
4+
---
5+
6+
# unstable_RouterContextProvider
7+
8+
<!--
9+
⚠️ ⚠️ IMPORTANT ⚠️ ⚠️
10+
11+
Thank you for helping improve our documentation!
12+
13+
This file is auto-generated from the JSDoc comments in the source
14+
code, so please edit the JSDoc comments in the file below and this
15+
file will be re-generated once those changes are merged.
16+
17+
https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/utils.ts
18+
-->
19+
20+
[MODES: framework, data]
21+
22+
<br />
23+
<br />
24+
25+
<docs-warning>This API is experimental and subject to breaking changes in
26+
minor/patch releases. Please use with caution and pay **very** close attention
27+
to release notes for relevant changes.</docs-warning>
28+
29+
## Summary
30+
31+
[Reference Documentation ↗](https://api.reactrouter.com/v7/classes/react_router.unstable_RouterContextProvider.html)
32+
33+
Provides methods for writing/reading values in application context in a
34+
type-safe way. Primarily for usage with [Middleware](../../how-to/middleware).
35+
36+
```tsx
37+
import {
38+
unstable_createContext,
39+
unstable_RouterContextProvider
40+
} from "react-router";
41+
42+
const userContext = unstable_createContext<User | null>(null);
43+
const contextProvider = new unstable_RouterContextProvider();
44+
contextProvider.set(userContext, getUser());
45+
const user = contextProvider.get(userContext);
46+
// ^ User
47+
```
48+

docs/api/utils/createContext.md

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,40 @@ unstable: true
55

66
# unstable_createContext
77

8-
[MODES: framework, data]
9-
10-
<br/>
11-
<br/>
12-
13-
<docs-warning>This API is experimental and subject to breaking changes. Enable it with the `future.unstable_middleware` flag.</docs-warning>
14-
15-
## Summary
8+
<!--
9+
⚠️ ⚠️ IMPORTANT ⚠️ ⚠️
1610
17-
[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.unstable_createContext.html)
11+
Thank you for helping improve our documentation!
1812
19-
Creates a type-safe context object that can be used to store and retrieve values in middleware, loaders, and actions. Similar to React's `createContext`, but designed for React Router's request/response lifecycle.
13+
This file is auto-generated from the JSDoc comments in the source
14+
code, so please edit the JSDoc comments in the file below and this
15+
file will be re-generated once those changes are merged.
2016
21-
## Signature
17+
https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/router/utils.ts
18+
-->
2219

23-
```tsx
24-
unstable_createContext<T>(defaultValue?: T): RouterContext<T>
25-
```
20+
[MODES: framework, data]
2621

27-
## Params
22+
<br />
23+
<br />
2824

29-
### defaultValue
25+
<docs-warning>This API is experimental and subject to breaking changes in
26+
minor/patch releases. Please use with caution and pay **very** close attention
27+
to release notes for relevant changes.</docs-warning>
3028

31-
An optional default value for the context. This value will be returned if no value has been set for this context.
32-
33-
## Returns
29+
## Summary
3430

35-
A `RouterContext<T>` object that can be used with `context.get()` and `context.set()` in middleware, loaders, and actions.
31+
[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.unstable_createContext.html)
3632

37-
## Examples
33+
Creates a type-safe context object that can be used to store and retrieve
34+
values in middleware, [loaders](../../start/framework/route-module#loader),
35+
and [actions](../../start/framework/route-module#action). Similar to React's
36+
[`createContext`](https://react.dev/reference/react/createContext), but
37+
designed for React Router's request/response lifecycle.
3838

39-
### Basic Usage
39+
If a `defaultValue` is provided, it will be returned from `context.get()` when
40+
no value has been set for the context. Otherwise reading this context when no
41+
value has been set will throw an error.
4042

4143
```tsx filename=app/context.ts
4244
import { unstable_createContext } from "react-router";
@@ -75,6 +77,22 @@ export async function loader({
7577
}
7678
```
7779

78-
## See Also
80+
## Signature
81+
82+
```tsx
83+
function unstable_createContext<T>(
84+
defaultValue?: T,
85+
): unstable_RouterContext<T>
86+
```
87+
88+
## Params
89+
90+
### defaultValue
91+
92+
An optional default value for the context. This value will be returned if no value has been set for this context.
93+
94+
## Returns
95+
96+
A [`unstable_RouterContext`](https://api.reactrouter.com/v7/interfaces/react_router.unstable_RouterContext.html) object that can be used with
97+
`context.get()` and `context.set()` in middleware, loaders, and actions.
7998

80-
- [Middleware Guide](../../how-to/middleware)

docs/api/utils/data.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,58 @@ title: data
44

55
# data
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/router/utils.ts
17+
-->
18+
719
[MODES: framework, data]
820

921
## Summary
1022

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

1325
Create "responses" that contain `status`/`headers` without forcing
14-
serialization into an actual `Response` - used by Remix single fetch
26+
serialization into an actual `Response`
27+
28+
```tsx
29+
import { data } from "react-router";
30+
31+
export async function action({ request }) {
32+
let formData = await request.formData();
33+
let item = await createItem(formData);
34+
return data(item, {
35+
status: 201,
36+
headers: { "X-Custom-Header": "value" }
37+
});
38+
}
39+
```
1540

1641
## Signature
1742

1843
```tsx
19-
data(data, init): DataWithResponseInit
44+
function data<D>(data: D, init?: number | ResponseInit)
2045
```
2146

2247
## Params
2348

2449
### data
2550

26-
[modes: framework, data]
27-
28-
_No documentation_
51+
The data to be included in the response.
2952

3053
### init
3154

32-
[modes: framework, data]
55+
The status code or a `ResponseInit` object to be included in the response.
56+
57+
## Returns
58+
59+
A `DataWithResponseInit` instance containing the data and response
60+
init.
3361

34-
_No documentation_

docs/api/utils/generatePath.md

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

55
# generatePath
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/router/utils.ts
17+
-->
18+
719
[MODES: framework, data, declarative]
820

921
## Summary
@@ -12,22 +24,34 @@ title: generatePath
1224

1325
Returns a path with params interpolated.
1426

27+
```tsx
28+
import { generatePath } from "react-router";
29+
30+
generatePath("/users/:id", { id: "123" }); // "/users/123"
31+
```
32+
1533
## Signature
1634

1735
```tsx
18-
generatePath(originalPath, params): string
36+
function generatePath<Path extends string>(
37+
originalPath: Path,
38+
params: {
39+
[key in PathParam<Path>]: string | null;
40+
} = as any,
41+
): string {}
1942
```
2043

2144
## Params
2245

2346
### originalPath
2447

25-
[modes: framework, data, declarative]
26-
27-
_No documentation_
48+
The original path to generate.
2849

2950
### params
3051

31-
[modes: framework, data, declarative]
52+
The parameters to interpolate into the path.
53+
54+
## Returns
55+
56+
The generated path with parameters interpolated.
3257

33-
_No documentation_

0 commit comments

Comments
 (0)