Skip to content

Commit 7310da1

Browse files
committed
chore: generate markdown docs from jsdocs
1 parent 7fcb5fe commit 7310da1

39 files changed

+925
-312
lines changed

docs/api/components/Form.md

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

55
# Form
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/dom/lib.tsx#L1210
17+
-->
18+
719
[MODES: framework, data]
820

921
## Summary
@@ -33,33 +45,39 @@ function NewEvent() {
3345

3446
### action
3547

36-
[modes: framework, data]
37-
38-
The URL to submit the form data to. If `undefined`, this defaults to the closest route in context.
48+
The URL to submit the form data to. If `undefined`, this defaults to the
49+
closest route in context.
3950

4051
### discover
4152

42-
[modes: framework, data]
53+
Defines the link discovery behavior. See [`DiscoverBehavior`](https://api.reactrouter.com/v7/types/react_router.DiscoverBehavior.html).
54+
55+
```tsx
56+
<Link /> // default ("render")
57+
<Link discover="render" />
58+
<Link discover="none" />
59+
```
4360

44-
Determines application manifest discovery behavior.
61+
- **render** - default, discover the route when the link renders
62+
- **none** - don't eagerly discover, only discover if the link is clicked
4563

4664
### encType
4765

48-
[modes: framework, data]
49-
5066
The encoding type to use for the form submission.
5167

52-
### fetcherKey
68+
```tsx
69+
<Form encType="application/x-www-form-urlencoded"/> // Default
70+
<Form encType="multipart/form-data"/>
71+
<Form encType="text/plain"/>
72+
```
5373

54-
[modes: framework, data]
74+
### fetcherKey
5575

5676
Indicates a specific fetcherKey to use when using `navigate={false}` so you
57-
can pick up the fetcher's state in a different component in a [useFetcher](../hooks/useFetcher).
77+
can pick up the fetcher's state in a different component in a [`useFetcher`](../hooks/useFetcher).
5878

5979
### method
6080

61-
[modes: framework, data]
62-
6381
The HTTP verb to use when the form is submitted. Supports "get", "post",
6482
"put", "delete", and "patch".
6583

@@ -68,61 +86,46 @@ you'd like to support progressive enhancement
6886

6987
### navigate
7088

71-
[modes: framework, data]
72-
73-
Skips the navigation and uses a [useFetcher](../hooks/useFetcher) internally
74-
when `false`. This is essentially a shorthand for `useFetcher()` +
75-
`<fetcher.Form>` where you don't care about the resulting data in this
76-
component.
89+
When `false`, skips the navigation and submits via a fetcher internally.
90+
This is essentially a shorthand for [`useFetcher`](../hooks/useFetcher) + `<fetcher.Form>` where
91+
you don't care about the resulting data in this component.
7792

7893
### onSubmit
7994

80-
[modes: framework, data]
81-
8295
A function to call when the form is submitted. If you call
8396
`event.preventDefault()` then this form will not do anything.
8497

8598
### preventScrollReset
8699

87-
[modes: framework, data]
88-
89100
Prevent the scroll position from resetting to the top of the viewport on
90101
completion of the navigation when using the <ScrollRestoration> component
91102

92103
### relative
93104

94-
[modes: framework, data]
95-
96105
Determines whether the form action is relative to the route hierarchy or
97-
the pathname. Use this if you want to opt out of navigating the route
98-
hierarchy and want to instead route based on /-delimited URL segments
106+
the pathname. Use this if you want to opt out of navigating the route
107+
hierarchy and want to instead route based on slash-delimited URL segments.
108+
See [`RelativeRoutingType`](https://api.reactrouter.com/v7/types/react_router.RelativeRoutingType.html).
99109

100110
### reloadDocument
101111

102-
[modes: framework, data]
103-
104112
Forces a full document navigation instead of client side routing + data
105113
fetch.
106114

107115
### replace
108116

109-
[modes: framework, data]
110-
111117
Replaces the current entry in the browser history stack when the form
112118
navigates. Use this if you don't want the user to be able to click "back"
113119
to the page with the form on it.
114120

115121
### state
116122

117-
[modes: framework, data]
118-
119123
State object to add to the history stack entry for this navigation
120124

121125
### viewTransition
122126

123-
[modes: framework, data]
124-
125127
Enables a [View
126128
Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
127129
for this navigation. To apply specific styles during the transition see
128-
[useViewTransitionState](../hooks/useViewTransitionState).
130+
[`useViewTransitionState`](../hooks/useViewTransitionState).
131+

docs/api/components/Link.md

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

55
# Link
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/dom/lib.tsx#L641
17+
-->
18+
719
[MODES: framework, data, declarative]
820

921
## Summary
@@ -35,7 +47,9 @@ import { Link } from "react-router";
3547
Defines the link discovery behavior
3648

3749
```tsx
50+
<Link /> // default ("render")
3851
<Link discover="render" />
52+
<Link discover="none" />
3953
```
4054

4155
- **render** - default, discover the route when the link renders
@@ -48,29 +62,39 @@ Defines the link discovery behavior
4862
Defines the data and module prefetching behavior for the link.
4963

5064
```tsx
65+
<Link /> // default
66+
<Link prefetch="none" />
5167
<Link prefetch="intent" />
68+
<Link prefetch="render" />
69+
<Link prefetch="viewport" />
5270
```
5371

5472
- **none** - default, no prefetching
5573
- **intent** - prefetches when the user hovers or focuses the link
5674
- **render** - prefetches when the link renders
5775
- **viewport** - prefetches when the link is in the viewport, very useful for mobile
5876

59-
Prefetching is done with HTML `<link rel="prefetch">` tags. They are inserted after the link.
77+
Prefetching is done with HTML `<link rel="prefetch">` tags. They are inserted
78+
after the link.
6079

6180
```tsx
6281
<a href="..." />
6382
<a href="..." />
6483
<link rel="prefetch" /> // might conditionally render
6584
```
6685

67-
Because of this, if you are using `nav :last-child` you will need to use `nav :last-of-type` so the styles don't conditionally fall off your last link (and any other similar selectors).
86+
Because of this, if you are using `nav :last-child` you will need to use
87+
`nav :last-of-type` so the styles don't conditionally fall off your last link
88+
(and any other similar selectors).
6889

6990
### preventScrollReset
7091

7192
[modes: framework, data]
7293

73-
Prevents the scroll position from being reset to the top of the window when the link is clicked and the app is using [ScrollRestoration](../components/ScrollRestoration). This only prevents new locations reseting scroll to the top, scroll position will be restored for back/forward button navigation.
94+
Prevents the scroll position from being reset to the top of the window when
95+
the link is clicked and the app is using [`ScrollRestoration`](../components/ScrollRestoration). This only
96+
prevents new locations reseting scroll to the top, scroll position will be
97+
restored for back/forward button navigation.
7498

7599
```tsx
76100
<Link to="?tab=one" preventScrollReset />
@@ -88,18 +112,24 @@ Defines the relative path behavior for the link.
88112
<Link relative="path" />
89113
```
90114

91-
Consider a route hierarchy where a parent route pattern is "blog" and a child route pattern is "blog/:slug/edit".
115+
Consider a route hierarchy where a parent route pattern is "blog" and a child
116+
route pattern is "blog/:slug/edit".
92117

93-
- **route** - default, resolves the link relative to the route pattern. In the example above a relative link of `".."` will remove both `:slug/edit` segments back to "/blog".
94-
- **path** - relative to the path so `..` will only remove one URL segment up to "/blog/:slug"
118+
- **route** - default, resolves the link relative to the route pattern. In the
119+
example above a relative link of `".."` will remove both `:slug/edit` segments
120+
back to "/blog".
121+
- **path** - relative to the path so `..` will only remove one URL segment up
122+
to "/blog/:slug"
95123

96-
Note that index routes and layout routes have no paths so they are not included in the relative path calculation.
124+
Note that index routes and layout routes do not have paths so they are not
125+
included in the relative path calculation.
97126

98127
### reloadDocument
99128

100129
[modes: framework, data, declarative]
101130

102-
Will use document navigation instead of client side routing when the link is clicked: the browser will handle the transition normally (as if it were an `<a href>`).
131+
Will use document navigation instead of client side routing when the link is
132+
clicked: the browser will handle the transition normally (as if it were an `<a href>`).
103133

104134
```tsx
105135
<Link to="/logout" reloadDocument />
@@ -109,7 +139,8 @@ Will use document navigation instead of client side routing when the link is cli
109139

110140
[modes: framework, data, declarative]
111141

112-
Replaces the current entry in the history stack instead of pushing a new one onto it.
142+
Replaces the current entry in the history stack instead of pushing a new one
143+
onto it.
113144

114145
```tsx
115146
<Link replace />
@@ -145,13 +176,14 @@ function SomeComp() {
145176
}
146177
```
147178

148-
This state is inaccessible on the server as it is implemented on top of [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state)
179+
This state is inaccessible on the server as it is implemented on top of
180+
[`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state)
149181

150182
### to
151183

152184
[modes: framework, data, declarative]
153185

154-
Can be a string or a partial [Path](https://api.reactrouter.com/v7/interfaces/react_router.Path.html):
186+
Can be a string or a partial [`Path`](https://api.reactrouter.com/v7/interfaces/react_router.Path.html):
155187

156188
```tsx
157189
<Link to="/some/path" />
@@ -167,14 +199,16 @@ Can be a string or a partial [Path](https://api.reactrouter.com/v7/interfaces/re
167199

168200
### viewTransition
169201

170-
[modes: framework, data, declarative]
202+
[modes: framework, data]
171203

172-
Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API) for this navigation.
204+
Enables a [View Transition](https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API)
205+
for this navigation.
173206

174207
```jsx
175208
<Link to={to} viewTransition>
176209
Click me
177210
</Link>
178211
```
179212

180-
To apply specific styles for the transition, see [useViewTransitionState](../hooks/useViewTransitionState)
213+
To apply specific styles for the transition, see [`useViewTransitionState`](../hooks/useViewTransitionState)
214+

0 commit comments

Comments
 (0)