Skip to content

Commit 8628a77

Browse files
committed
chore: generate markdown docs from jsdocs
1 parent 9198d9f commit 8628a77

14 files changed

+98
-83
lines changed

docs/api/data-routers/createBrowserRouter.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ 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` indicates
77-
if the handler was successful or not based on the `DataStrategyResult.type`
76+
routes where a handler was executed. A `DataStrategyResult` indicates if
77+
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)
8080
or [`res.text`](https://developer.mozilla.org/en-US/docs/Web/API/Response/text)).
@@ -238,11 +238,10 @@ Future flags to enable for the router.
238238
### opts.unstable_getContext
239239

240240
A function that returns an [`unstable_RouterContextProvider`](../utils/RouterContextProvider) instance
241-
which is provided as the `context` argument to client
242-
[`action`](../../start/data/route-object#action)s,
243-
[`loader`](../../start/data/route-object#loader)s and
244-
[`middleware`](../../how-to/middleware)s. This function is called to
245-
generate a fresh `context` instance on each navigation or fetcher call.
241+
which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
242+
[`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
243+
This function is called to generate a fresh `context` instance on each
244+
navigation or fetcher call.
246245

247246
### opts.hydrationData
248247

@@ -270,15 +269,16 @@ server-rendered app. But in advanced use-cases (such as Framework Mode's
270269
[`clientLoader`](../../start/framework/route-module#clientLoader)), you may
271270
want to include `loaderData` for only some routes that were loaded/rendered
272271
on the server. This allows you to hydrate _some_ of the routes (such as the
273-
app layout/shell) while showing a `HydrateFallback`
274-
component and running the [`loader`](../../start/data/route-object#loader)s
275-
for other routes during hydration.
272+
app layout/shell) while showing a `HydrateFallback` component and running
273+
the [`loader`](../../start/data/route-object#loader)s for other routes
274+
during hydration.
276275

277276
A route [`loader`](../../start/data/route-object#loader) will run during
278277
hydration in two scenarios:
279278

280279
1. No hydration data is provided
281-
In these cases the `HydrateFallback` component will render on initial hydration
280+
In these cases the `HydrateFallback` component will render on initial
281+
hydration
282282
2. The `loader.hydrate` property is set to `true`
283283
This allows you to run the [`loader`](../../start/data/route-object#loader)
284284
even if you did not render a fallback on initial hydration (i.e., to
@@ -349,11 +349,11 @@ the app - but would only ever end up loading portions of the tree that the
349349
user visited.
350350

351351
`patchRoutesOnNavigation` will be called anytime React Router is unable to
352-
match a `path`. The arguments include the `path`, any partial
353-
`matches`, and a `patch` function you can call to patch
354-
new routes into the tree at a specific location. This method is executed
355-
during the `loading` portion of the navigation for `GET` requests and during
356-
the `submitting` portion of the navigation for non-`GET` requests.
352+
match a `path`. The arguments include the `path`, any partial `matches`,
353+
and a `patch` function you can call to patch new routes into the tree at a
354+
specific location. This method is executed during the `loading` portion of
355+
the navigation for `GET` requests and during the `submitting` portion of
356+
the navigation for non-`GET` requests.
357357

358358
<details>
359359
<summary><b>Example <code>patchRoutesOnNavigation</code> Use Cases</b></summary>

docs/api/data-routers/createHashRouter.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@ Future flags to enable for the router.
5151
### opts.unstable_getContext
5252

5353
A function that returns an [`unstable_RouterContextProvider`](../utils/RouterContextProvider) instance
54-
which is provided as the `context` argument to client
55-
[`action`](../../start/data/route-object#action)s,
56-
[`loader`](../../start/data/route-object#loader)s and
57-
[`middleware`](../../how-to/middleware)s. This function is called to
58-
generate a fresh `context` instance on each navigation or fetcher call.
54+
which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
55+
[`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
56+
This function is called to generate a fresh `context` instance on each
57+
navigation or fetcher call.
5958

6059
### opts.hydrationData
6160

@@ -83,15 +82,16 @@ server-rendered app. But in advanced use-cases (such as Framework Mode's
8382
[`clientLoader`](../../start/framework/route-module#clientLoader)), you may
8483
want to include `loaderData` for only some routes that were loaded/rendered
8584
on the server. This allows you to hydrate _some_ of the routes (such as the
86-
app layout/shell) while showing a `HydrateFallback`
87-
component and running the [`loader`](../../start/data/route-object#loader)s
88-
for other routes during hydration.
85+
app layout/shell) while showing a `HydrateFallback` component and running
86+
the [`loader`](../../start/data/route-object#loader)s for other routes
87+
during hydration.
8988

9089
A route [`loader`](../../start/data/route-object#loader) will run during
9190
hydration in two scenarios:
9291

9392
1. No hydration data is provided
94-
In these cases the `HydrateFallback` component will render on initial hydration
93+
In these cases the `HydrateFallback` component will render on initial
94+
hydration
9595
2. The `loader.hydrate` property is set to `true`
9696
This allows you to run the [`loader`](../../start/data/route-object#loader)
9797
even if you did not render a fallback on initial hydration (i.e., to
@@ -153,8 +153,8 @@ application's data needs.
153153

154154
The `dataStrategy` function should return a key/value-object of
155155
`routeId` -> [`DataStrategyResult`](https://api.reactrouter.com/v7/interfaces/react_router.DataStrategyResult.html) and should include entries for any
156-
routes where a handler was executed. A `DataStrategyResult` indicates
157-
if the handler was successful or not based on the `DataStrategyResult.type`
156+
routes where a handler was executed. A `DataStrategyResult` indicates if
157+
the handler was successful or not based on the `DataStrategyResult.type`
158158
field. If the returned `DataStrategyResult.result` is a [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response),
159159
React Router will unwrap it for you (via [`res.json`](https://developer.mozilla.org/en-US/docs/Web/API/Response/json)
160160
or [`res.text`](https://developer.mozilla.org/en-US/docs/Web/API/Response/text)).
@@ -348,11 +348,11 @@ the app - but would only ever end up loading portions of the tree that the
348348
user visited.
349349
350350
`patchRoutesOnNavigation` will be called anytime React Router is unable to
351-
match a `path`. The arguments include the `path`, any partial
352-
`matches`, and a `patch` function you can call to patch
353-
new routes into the tree at a specific location. This method is executed
354-
during the `loading` portion of the navigation for `GET` requests and during
355-
the `submitting` portion of the navigation for non-`GET` requests.
351+
match a `path`. The arguments include the `path`, any partial `matches`,
352+
and a `patch` function you can call to patch new routes into the tree at a
353+
specific location. This method is executed during the `loading` portion of
354+
the navigation for `GET` requests and during the `submitting` portion of
355+
the navigation for non-`GET` requests.
356356
357357
<details>
358358
<summary><b>Example <code>patchRoutesOnNavigation</code> Use Cases</b></summary>

docs/api/data-routers/createMemoryRouter.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ Future flags to enable for the router.
5656

5757
### opts.unstable_getContext
5858

59-
Function to provide the initial context values for all client side
60-
navigations/fetches
59+
A function that returns an [`unstable_RouterContextProvider`](../utils/RouterContextProvider) instance
60+
which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
61+
[`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
62+
This function is called to generate a fresh `context` instance on each
63+
navigation or fetcher call.
6164

6265
### opts.hydrationData
6366

docs/api/rsc/RSCHydratedRouter.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,10 @@ Optional fetch implementation. Defaults to global [`fetch`](https://developer.mo
8383
### unstable_getContext
8484

8585
A function that returns an [`unstable_RouterContextProvider`](../utils/RouterContextProvider) instance
86-
which is provided as the `context` argument to client
87-
[`action`](../../start/data/route-object#action)s,
88-
[`loader`](../../start/data/route-object#loader)s and
89-
[`middleware`](../../how-to/middleware)s. This function is called to
90-
generate a fresh `context` instance on each navigation or fetcher call.
86+
which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
87+
[`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
88+
This function is called to generate a fresh `context` instance on each
89+
navigation or fetcher call.
9190

9291
### payload
9392

docs/api/utils/RouterContextProvider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ to release notes for relevant changes.</docs-warning>
3131
[Reference Documentation ↗](https://api.reactrouter.com/v7/classes/react_router.unstable_RouterContextProvider.html)
3232

3333
Provides methods for writing/reading values in application context in a
34-
type-safe way. Primarily for usage with [Middleware](../../how-to/middleware).
34+
type-safe way. Primarily for usage with [middleware](../../how-to/middleware).
3535

3636
```tsx
3737
import {

docs/api/utils/createContext.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ to release notes for relevant changes.</docs-warning>
3030

3131
[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.unstable_createContext.html)
3232

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.
33+
Creates a type-safe [`unstable_RouterContext`](https://api.reactrouter.com/v7/interfaces/react_router.unstable_RouterContext.html) object that can be used to
34+
* store and retrieve arbitrary values in [`action`](../../start/framework/route-module#action)s,
35+
* [`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
36+
* Similar to React's [`createContext`](https://react.dev/reference/react/createContext),
37+
* but specifically designed for React Router's request/response lifecycle.
3838

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.
39+
<docs-warning>Enable this API with the `future.unstable_middleware` flag.</docs-warning>
40+
41+
If a `defaultValue` is provided, it will be returned from `context.get()`
42+
when no value has been set for the context. Otherwise, reading this context
43+
when no value has been set will throw an error.
4244

4345
```tsx filename=app/context.ts
4446
import { unstable_createContext } from "react-router";
@@ -49,12 +51,12 @@ export const userContext =
4951
```
5052

5153
```tsx filename=app/middleware/auth.ts
52-
import { userContext } from "~/context";
5354
import { getUserFromSession } from "~/auth.server";
55+
import { userContext } from "~/context";
5456

5557
export const authMiddleware = async ({
56-
request,
5758
context,
59+
request,
5860
}) => {
5961
const user = await getUserFromSession(request);
6062
context.set(userContext, user);
@@ -94,5 +96,6 @@ An optional default value for the context. This value will be returned if no val
9496
## Returns
9597

9698
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.
99+
`context.get()` and `context.set()` in [`action`](../../start/framework/route-module#action)s,
100+
[`loader`](../../start/framework/route-module#loader)s, and [middleware](../../how-to/middleware).
98101

docs/api/utils/data.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/ro
2222

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

25-
Create "responses" that contain `status`/`headers` without forcing
26-
serialization into an actual `Response`
25+
Create "responses" that contain `headers`/`status` without forcing
26+
serialization into an actual [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
2727

2828
```tsx
2929
import { data } from "react-router";
3030

31-
export async function action({ request }) {
31+
export async function action({ request }: Route.ActionArgs) {
3232
let formData = await request.formData();
3333
let item = await createItem(formData);
3434
return data(item, {
35-
status: 201,
3635
headers: { "X-Custom-Header": "value" }
36+
status: 201,
3737
});
3838
}
3939
```
@@ -56,6 +56,6 @@ The status code or a `ResponseInit` object to be included in the response.
5656

5757
## Returns
5858

59-
A `DataWithResponseInit` instance containing the data and response
60-
init.
59+
A `DataWithResponseInit` instance containing the data and
60+
response init.
6161

docs/api/utils/isRouteErrorResponse.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ https://github.com/remix-run/react-router/blob/main/packages/react-router/lib/ro
2222

2323
[Reference Documentation ↗](https://api.reactrouter.com/v7/functions/react_router.isRouteErrorResponse.html)
2424

25-
Check if the given error is an ErrorResponse generated from a 4xx/5xx
26-
Response thrown from an action/loader
25+
Check if the given error is an [`ErrorResponse`](https://api.reactrouter.com/v7/types/react_router.ErrorResponse.html) generated from a 4xx/5xx
26+
[`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response)
27+
thrown from an [`action`](../../start/framework/route-module#action)/[`loader`](../../start/framework/route-module#loader)
2728

2829
```tsx
2930
import { isRouteErrorResponse } from "react-router";
@@ -32,7 +33,7 @@ export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
3233
if (isRouteErrorResponse(error)) {
3334
return (
3435
<>
35-
<p>Error: {{error.status}: {error.statusText}}</p>
36+
<p>Error: `${error.status}: ${error.statusText}`</p>
3637
<p>{error.data}</p>
3738
</>
3839
);
@@ -58,5 +59,5 @@ The error to check.
5859

5960
## Returns
6061

61-
`true` if the error is an `ErrorResponse`, `false` otherwise.
62+
`true` if the error is an [`ErrorResponse`](https://api.reactrouter.com/v7/types/react_router.ErrorResponse.html), `false` otherwise.
6263

docs/api/utils/matchPath.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ function matchPath<ParamKey extends ParamParseKey<Path>, Path extends string>(
3838

3939
### pattern
4040

41-
The pattern to match against the URL pathname. This can be a string or a [`PathPattern`](https://api.reactrouter.com/v7/interfaces/react_router.PathPattern.html) object. If a string is provided, it will
42-
be treated as a pattern with `caseSensitive` set to `false` and `end
43-
set to `true`.
41+
The pattern to match against the URL pathname. This can be a string or a [`PathPattern`](https://api.reactrouter.com/v7/interfaces/react_router.PathPattern.html) object. If a string is provided, it will be
42+
treated as a pattern with `caseSensitive` set to `false` and `end` set to
43+
`true`.
4444

4545
### pathname
4646

docs/api/utils/matchRoutes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The location to match against, either a string path or a partial [`Location`](ht
6363

6464
### basename
6565

66-
Optional base path to strip from the location before matching.
66+
Optional base path to strip from the location before matching. Defaults to `/`.
6767

6868
## Returns
6969

0 commit comments

Comments
 (0)