react-router-dom 5.2.0 → 6.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +345 -0
- package/{LICENSE → LICENSE.md} +3 -1
- package/README.md +4 -36
- package/dist/dom.d.ts +76 -0
- package/dist/index.d.ts +246 -0
- package/dist/index.js +1058 -0
- package/dist/index.js.map +1 -0
- package/dist/main.js +19 -0
- package/dist/react-router-dom.development.js +1005 -0
- package/dist/react-router-dom.development.js.map +1 -0
- package/dist/react-router-dom.production.min.js +12 -0
- package/dist/react-router-dom.production.min.js.map +1 -0
- package/dist/server.d.ts +28 -0
- package/dist/server.js +319 -0
- package/dist/server.mjs +291 -0
- package/dist/umd/react-router-dom.development.js +1306 -0
- package/dist/umd/react-router-dom.development.js.map +1 -0
- package/dist/umd/react-router-dom.production.min.js +12 -0
- package/dist/umd/react-router-dom.production.min.js.map +1 -0
- package/package.json +38 -54
- package/server.d.ts +28 -0
- package/server.js +319 -0
- package/server.mjs +291 -0
- package/BrowserRouter.js +0 -3
- package/HashRouter.js +0 -3
- package/Link.js +0 -3
- package/MemoryRouter.js +0 -3
- package/NavLink.js +0 -3
- package/Prompt.js +0 -3
- package/Redirect.js +0 -3
- package/Route.js +0 -3
- package/Router.js +0 -3
- package/StaticRouter.js +0 -3
- package/Switch.js +0 -3
- package/cjs/react-router-dom.js +0 -443
- package/cjs/react-router-dom.js.map +0 -1
- package/cjs/react-router-dom.min.js +0 -2
- package/cjs/react-router-dom.min.js.map +0 -1
- package/es/BrowserRouter.js +0 -5
- package/es/HashRouter.js +0 -5
- package/es/Link.js +0 -5
- package/es/MemoryRouter.js +0 -5
- package/es/NavLink.js +0 -5
- package/es/Prompt.js +0 -5
- package/es/Redirect.js +0 -5
- package/es/Route.js +0 -5
- package/es/Router.js +0 -5
- package/es/StaticRouter.js +0 -5
- package/es/Switch.js +0 -5
- package/es/generatePath.js +0 -5
- package/es/matchPath.js +0 -5
- package/es/warnAboutDeprecatedESMImport.js +0 -34
- package/es/withRouter.js +0 -5
- package/esm/react-router-dom.js +0 -317
- package/esm/react-router-dom.js.map +0 -1
- package/generatePath.js +0 -3
- package/index.js +0 -7
- package/matchPath.js +0 -3
- package/modules/BrowserRouter.js +0 -36
- package/modules/HashRouter.js +0 -35
- package/modules/Link.js +0 -146
- package/modules/NavLink.js +0 -125
- package/modules/index.js +0 -21
- package/modules/utils/locationUtils.js +0 -10
- package/umd/react-router-dom.js +0 -3969
- package/umd/react-router-dom.js.map +0 -1
- package/umd/react-router-dom.min.js +0 -2
- package/umd/react-router-dom.min.js.map +0 -1
- package/warnAboutDeprecatedCJSRequire.js +0 -36
- package/withRouter.js +0 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
# `react-router-dom`
|
|
2
|
+
|
|
3
|
+
## 6.11.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Export `SetURLSearchParams` type ([#10444](https://github.com/remix-run/react-router/pull/10444))
|
|
8
|
+
- Updated dependencies:
|
|
9
|
+
- `react-router@6.11.2`
|
|
10
|
+
- `@remix-run/router@1.6.2`
|
|
11
|
+
|
|
12
|
+
## 6.11.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies:
|
|
17
|
+
- `react-router@6.11.1`
|
|
18
|
+
- `@remix-run/router@1.6.1`
|
|
19
|
+
|
|
20
|
+
## 6.11.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- Enable `basename` support in `useFetcher` ([#10336](https://github.com/remix-run/react-router/pull/10336))
|
|
25
|
+
- If you were previously working around this issue by manually prepending the `basename` then you will need to remove the manually prepended `basename` from your `fetcher` calls (`fetcher.load('/basename/route') -> fetcher.load('/route')`)
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Fix inadvertent re-renders when using `Component` instead of `element` on a route definition ([#10287](https://github.com/remix-run/react-router/pull/10287))
|
|
30
|
+
- Fail gracefully on `<Link to="//">` and other invalid URL values ([#10367](https://github.com/remix-run/react-router/pull/10367))
|
|
31
|
+
- Switched from `useSyncExternalStore` to `useState` for internal `@remix-run/router` router state syncing in `<RouterProvider>`. We found some [subtle bugs](https://codesandbox.io/s/use-sync-external-store-loop-9g7b81) where router state updates got propagated _before_ other normal `useState` updates, which could lead to footguns in `useEffect` calls. ([#10377](https://github.com/remix-run/react-router/pull/10377), [#10409](https://github.com/remix-run/react-router/pull/10409))
|
|
32
|
+
- Add static prop to `StaticRouterProvider`'s internal `Router` component ([#10401](https://github.com/remix-run/react-router/pull/10401))
|
|
33
|
+
- When using a `RouterProvider`, `useNavigate`/`useSubmit`/`fetcher.submit` are now stable across location changes, since we can handle relative routing via the `@remix-run/router` instance and get rid of our dependence on `useLocation()`. When using `BrowserRouter`, these hooks remain unstable across location changes because they still rely on `useLocation()`. ([#10336](https://github.com/remix-run/react-router/pull/10336))
|
|
34
|
+
- Updated dependencies:
|
|
35
|
+
- `react-router@6.11.0`
|
|
36
|
+
- `@remix-run/router@1.6.0`
|
|
37
|
+
|
|
38
|
+
## 6.10.0
|
|
39
|
+
|
|
40
|
+
### Minor Changes
|
|
41
|
+
|
|
42
|
+
- Added support for [**Future Flags**](https://reactrouter.com/en/main/guides/api-development-strategy) in React Router. The first flag being introduced is `future.v7_normalizeFormMethod` which will normalize the exposed `useNavigation()/useFetcher()` `formMethod` fields as uppercase HTTP methods to align with the `fetch()` behavior. ([#10207](https://github.com/remix-run/react-router/pull/10207))
|
|
43
|
+
|
|
44
|
+
- When `future.v7_normalizeFormMethod === false` (default v6 behavior),
|
|
45
|
+
- `useNavigation().formMethod` is lowercase
|
|
46
|
+
- `useFetcher().formMethod` is lowercase
|
|
47
|
+
- When `future.v7_normalizeFormMethod === true`:
|
|
48
|
+
- `useNavigation().formMethod` is uppercase
|
|
49
|
+
- `useFetcher().formMethod` is uppercase
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Fix `createStaticHandler` to also check for `ErrorBoundary` on routes in addition to `errorElement` ([#10190](https://github.com/remix-run/react-router/pull/10190))
|
|
54
|
+
- Updated dependencies:
|
|
55
|
+
- `@remix-run/router@1.5.0`
|
|
56
|
+
- `react-router@6.10.0`
|
|
57
|
+
|
|
58
|
+
## 6.9.0
|
|
59
|
+
|
|
60
|
+
### Minor Changes
|
|
61
|
+
|
|
62
|
+
- React Router now supports an alternative way to define your route `element` and `errorElement` fields as React Components instead of React Elements. You can instead pass a React Component to the new `Component` and `ErrorBoundary` fields if you choose. There is no functional difference between the two, so use whichever approach you prefer 😀. You shouldn't be defining both, but if you do `Component`/`ErrorBoundary` will "win". ([#10045](https://github.com/remix-run/react-router/pull/10045))
|
|
63
|
+
|
|
64
|
+
**Example JSON Syntax**
|
|
65
|
+
|
|
66
|
+
```jsx
|
|
67
|
+
// Both of these work the same:
|
|
68
|
+
const elementRoutes = [{
|
|
69
|
+
path: '/',
|
|
70
|
+
element: <Home />,
|
|
71
|
+
errorElement: <HomeError />,
|
|
72
|
+
}]
|
|
73
|
+
|
|
74
|
+
const componentRoutes = [{
|
|
75
|
+
path: '/',
|
|
76
|
+
Component: Home,
|
|
77
|
+
ErrorBoundary: HomeError,
|
|
78
|
+
}]
|
|
79
|
+
|
|
80
|
+
function Home() { ... }
|
|
81
|
+
function HomeError() { ... }
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Example JSX Syntax**
|
|
85
|
+
|
|
86
|
+
```jsx
|
|
87
|
+
// Both of these work the same:
|
|
88
|
+
const elementRoutes = createRoutesFromElements(
|
|
89
|
+
<Route path='/' element={<Home />} errorElement={<HomeError /> } />
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const componentRoutes = createRoutesFromElements(
|
|
93
|
+
<Route path='/' Component={Home} ErrorBoundary={HomeError} />
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
function Home() { ... }
|
|
97
|
+
function HomeError() { ... }
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
- **Introducing Lazy Route Modules!** ([#10045](https://github.com/remix-run/react-router/pull/10045))
|
|
101
|
+
|
|
102
|
+
In order to keep your application bundles small and support code-splitting of your routes, we've introduced a new `lazy()` route property. This is an async function that resolves the non-route-matching portions of your route definition (`loader`, `action`, `element`/`Component`, `errorElement`/`ErrorBoundary`, `shouldRevalidate`, `handle`).
|
|
103
|
+
|
|
104
|
+
Lazy routes are resolved on initial load and during the `loading` or `submitting` phase of a navigation or fetcher call. You cannot lazily define route-matching properties (`path`, `index`, `children`) since we only execute your lazy route functions after we've matched known routes.
|
|
105
|
+
|
|
106
|
+
Your `lazy` functions will typically return the result of a dynamic import.
|
|
107
|
+
|
|
108
|
+
```jsx
|
|
109
|
+
// In this example, we assume most folks land on the homepage so we include that
|
|
110
|
+
// in our critical-path bundle, but then we lazily load modules for /a and /b so
|
|
111
|
+
// they don't load until the user navigates to those routes
|
|
112
|
+
let routes = createRoutesFromElements(
|
|
113
|
+
<Route path="/" element={<Layout />}>
|
|
114
|
+
<Route index element={<Home />} />
|
|
115
|
+
<Route path="a" lazy={() => import("./a")} />
|
|
116
|
+
<Route path="b" lazy={() => import("./b")} />
|
|
117
|
+
</Route>
|
|
118
|
+
);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Then in your lazy route modules, export the properties you want defined for the route:
|
|
122
|
+
|
|
123
|
+
```jsx
|
|
124
|
+
export async function loader({ request }) {
|
|
125
|
+
let data = await fetchData(request);
|
|
126
|
+
return json(data);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Export a `Component` directly instead of needing to create a React Element from it
|
|
130
|
+
export function Component() {
|
|
131
|
+
let data = useLoaderData();
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<>
|
|
135
|
+
<h1>You made it!</h1>
|
|
136
|
+
<p>{data}</p>
|
|
137
|
+
</>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Export an `ErrorBoundary` directly instead of needing to create a React Element from it
|
|
142
|
+
export function ErrorBoundary() {
|
|
143
|
+
let error = useRouteError();
|
|
144
|
+
return isRouteErrorResponse(error) ? (
|
|
145
|
+
<h1>
|
|
146
|
+
{error.status} {error.statusText}
|
|
147
|
+
</h1>
|
|
148
|
+
) : (
|
|
149
|
+
<h1>{error.message || error}</h1>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
An example of this in action can be found in the [`examples/lazy-loading-router-provider`](https://github.com/remix-run/react-router/tree/main/examples/lazy-loading-router-provider) directory of the repository.
|
|
155
|
+
|
|
156
|
+
🙌 Huge thanks to @rossipedia for the [Initial Proposal](https://github.com/remix-run/react-router/discussions/9826) and [POC Implementation](https://github.com/remix-run/react-router/pull/9830).
|
|
157
|
+
|
|
158
|
+
- Updated dependencies:
|
|
159
|
+
- `react-router@6.9.0`
|
|
160
|
+
- `@remix-run/router@1.4.0`
|
|
161
|
+
|
|
162
|
+
## 6.8.2
|
|
163
|
+
|
|
164
|
+
### Patch Changes
|
|
165
|
+
|
|
166
|
+
- Treat same-origin absolute URLs in `<Link to>` as external if they are outside of the router `basename` ([#10135](https://github.com/remix-run/react-router/pull/10135))
|
|
167
|
+
- Fix `useBlocker` to return `IDLE_BLOCKER` during SSR ([#10046](https://github.com/remix-run/react-router/pull/10046))
|
|
168
|
+
- Fix SSR of absolute `<Link to>` urls ([#10112](https://github.com/remix-run/react-router/pull/10112))
|
|
169
|
+
- Properly escape HTML characters in `StaticRouterProvider` serialized hydration data ([#10068](https://github.com/remix-run/react-router/pull/10068))
|
|
170
|
+
- Updated dependencies:
|
|
171
|
+
- `@remix-run/router@1.3.3`
|
|
172
|
+
- `react-router@6.8.2`
|
|
173
|
+
|
|
174
|
+
## 6.8.1
|
|
175
|
+
|
|
176
|
+
### Patch Changes
|
|
177
|
+
|
|
178
|
+
- Improved absolute url detection in `Link` component (now also supports `mailto:` urls) ([#9994](https://github.com/remix-run/react-router/pull/9994))
|
|
179
|
+
- Fix partial object (search or hash only) pathnames losing current path value ([#10029](https://github.com/remix-run/react-router/pull/10029))
|
|
180
|
+
- Updated dependencies:
|
|
181
|
+
- `react-router@6.8.1`
|
|
182
|
+
- `@remix-run/router@1.3.2`
|
|
183
|
+
|
|
184
|
+
## 6.8.0
|
|
185
|
+
|
|
186
|
+
### Minor Changes
|
|
187
|
+
|
|
188
|
+
- Support absolute URLs in `<Link to>`. If the URL is for the current origin, it will still do a client-side navigation. If the URL is for a different origin then it will do a fresh document request for the new origin. ([#9900](https://github.com/remix-run/react-router/pull/9900))
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
<Link to="https://neworigin.com/some/path"> {/* Document request */}
|
|
192
|
+
<Link to="//neworigin.com/some/path"> {/* Document request */}
|
|
193
|
+
<Link to="https://www.currentorigin.com/path"> {/* Client-side navigation */}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Patch Changes
|
|
197
|
+
|
|
198
|
+
- Fix bug with search params removal via `useSearchParams` ([#9969](https://github.com/remix-run/react-router/pull/9969))
|
|
199
|
+
- Respect `preventScrollReset` on `<fetcher.Form>` ([#9963](https://github.com/remix-run/react-router/pull/9963))
|
|
200
|
+
- Fix navigation for hash routers on manual URL changes ([#9980](https://github.com/remix-run/react-router/pull/9980))
|
|
201
|
+
- Use `pagehide` instead of `beforeunload` for `<ScrollRestoration>`. This has better cross-browser support, specifically on Mobile Safari. ([#9945](https://github.com/remix-run/react-router/pull/9945))
|
|
202
|
+
- Updated dependencies:
|
|
203
|
+
- `@remix-run/router@1.3.1`
|
|
204
|
+
- `react-router@6.8.0`
|
|
205
|
+
|
|
206
|
+
## 6.7.0
|
|
207
|
+
|
|
208
|
+
### Minor Changes
|
|
209
|
+
|
|
210
|
+
- Add `unstable_useBlocker` hook for blocking navigations within the app's location origin ([#9709](https://github.com/remix-run/react-router/pull/9709))
|
|
211
|
+
- Add `unstable_usePrompt` hook for blocking navigations within the app's location origin ([#9932](https://github.com/remix-run/react-router/pull/9932))
|
|
212
|
+
- Add `preventScrollReset` prop to `<Form>` ([#9886](https://github.com/remix-run/react-router/pull/9886))
|
|
213
|
+
|
|
214
|
+
### Patch Changes
|
|
215
|
+
|
|
216
|
+
- Added pass-through event listener options argument to `useBeforeUnload` ([#9709](https://github.com/remix-run/react-router/pull/9709))
|
|
217
|
+
- Streamline jsdom bug workaround in tests ([#9824](https://github.com/remix-run/react-router/pull/9824))
|
|
218
|
+
- Updated dependencies:
|
|
219
|
+
- `@remix-run/router@1.3.0`
|
|
220
|
+
- `react-router@6.7.0`
|
|
221
|
+
|
|
222
|
+
## 6.6.2
|
|
223
|
+
|
|
224
|
+
### Patch Changes
|
|
225
|
+
|
|
226
|
+
- Ensure `useId` consistency during SSR ([#9805](https://github.com/remix-run/react-router/pull/9805))
|
|
227
|
+
- Updated dependencies:
|
|
228
|
+
- `react-router@6.6.2`
|
|
229
|
+
|
|
230
|
+
## 6.6.1
|
|
231
|
+
|
|
232
|
+
### Patch Changes
|
|
233
|
+
|
|
234
|
+
- Updated dependencies:
|
|
235
|
+
- `@remix-run/router@1.2.1`
|
|
236
|
+
- `react-router@6.6.1`
|
|
237
|
+
|
|
238
|
+
## 6.6.0
|
|
239
|
+
|
|
240
|
+
### Minor Changes
|
|
241
|
+
|
|
242
|
+
- Add `useBeforeUnload()` hook ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
|
243
|
+
- Remove `unstable_` prefix from `createStaticHandler`/`createStaticRouter`/`StaticRouterProvider` ([#9738](https://github.com/remix-run/react-router/pull/9738))
|
|
244
|
+
|
|
245
|
+
### Patch Changes
|
|
246
|
+
|
|
247
|
+
- Proper hydration of `Error` objects from `StaticRouterProvider` ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
|
248
|
+
- Support uppercase `<Form method>` and `useSubmit` method values ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
|
249
|
+
- Skip initial scroll restoration for SSR apps with `hydrationData` ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
|
250
|
+
- Fix `<button formmethod>` form submission overriddes ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
|
251
|
+
- Updated dependencies:
|
|
252
|
+
- `@remix-run/router@1.2.0`
|
|
253
|
+
- `react-router@6.6.0`
|
|
254
|
+
|
|
255
|
+
## 6.5.0
|
|
256
|
+
|
|
257
|
+
### Patch Changes
|
|
258
|
+
|
|
259
|
+
- Updated dependencies:
|
|
260
|
+
- `react-router@6.5.0`
|
|
261
|
+
- `@remix-run/router@1.1.0`
|
|
262
|
+
|
|
263
|
+
## 6.4.5
|
|
264
|
+
|
|
265
|
+
### Patch Changes
|
|
266
|
+
|
|
267
|
+
- Updated dependencies:
|
|
268
|
+
- `@remix-run/router@1.0.5`
|
|
269
|
+
- `react-router@6.4.5`
|
|
270
|
+
|
|
271
|
+
## 6.4.4
|
|
272
|
+
|
|
273
|
+
### Patch Changes
|
|
274
|
+
|
|
275
|
+
- Fix issues with encoded characters in `NavLink` and descendant `<Routes>` ([#9589](https://github.com/remix-run/react-router/pull/9589), [#9647](https://github.com/remix-run/react-router/pull/9647))
|
|
276
|
+
- Properly serialize/deserialize `ErrorResponse` instances when using built-in hydration ([#9593](https://github.com/remix-run/react-router/pull/9593))
|
|
277
|
+
- Support `basename` in static data routers ([#9591](https://github.com/remix-run/react-router/pull/9591))
|
|
278
|
+
- Updated dependencies:
|
|
279
|
+
- `@remix-run/router@1.0.4`
|
|
280
|
+
- `react-router@6.4.4`
|
|
281
|
+
|
|
282
|
+
## 6.4.3
|
|
283
|
+
|
|
284
|
+
### Patch Changes
|
|
285
|
+
|
|
286
|
+
- Fix hrefs generated for `createHashRouter` ([#9409](https://github.com/remix-run/react-router/pull/9409))
|
|
287
|
+
- fix encoding/matching issues with special chars ([#9477](https://github.com/remix-run/react-router/pull/9477), [#9496](https://github.com/remix-run/react-router/pull/9496))
|
|
288
|
+
- Properly support `index` routes with a `path` in `useResolvedPath` ([#9486](https://github.com/remix-run/react-router/pull/9486))
|
|
289
|
+
- Respect `relative=path` prop on `NavLink` ([#9453](https://github.com/remix-run/react-router/pull/9453))
|
|
290
|
+
- Fix `NavLink` behavior for root urls ([#9497](https://github.com/remix-run/react-router/pull/9497))
|
|
291
|
+
- Updated dependencies:
|
|
292
|
+
- `@remix-run/router@1.0.3`
|
|
293
|
+
- `react-router@6.4.3`
|
|
294
|
+
|
|
295
|
+
## 6.4.2
|
|
296
|
+
|
|
297
|
+
### Patch Changes
|
|
298
|
+
|
|
299
|
+
- Respect `basename` in `useFormAction` ([#9352](https://github.com/remix-run/react-router/pull/9352))
|
|
300
|
+
- Enhance console error messages for invalid usage of data router hooks ([#9311](https://github.com/remix-run/react-router/pull/9311))
|
|
301
|
+
- If an index route has children, it will result in a runtime error. We have strengthened our `RouteObject`/`RouteProps` types to surface the error in TypeScript. ([#9366](https://github.com/remix-run/react-router/pull/9366))
|
|
302
|
+
- Updated dependencies:
|
|
303
|
+
- `react-router@6.4.2`
|
|
304
|
+
- `@remix-run/router@1.0.2`
|
|
305
|
+
|
|
306
|
+
## 6.4.1
|
|
307
|
+
|
|
308
|
+
### Patch Changes
|
|
309
|
+
|
|
310
|
+
- Updated dependencies:
|
|
311
|
+
- `react-router@6.4.1`
|
|
312
|
+
- `@remix-run/router@1.0.1`
|
|
313
|
+
|
|
314
|
+
## 6.4.0
|
|
315
|
+
|
|
316
|
+
Whoa this is a big one! `6.4.0` brings all the data loading and mutation APIs over from Remix. Here's a quick high level overview, but it's recommended you go check out the [docs][rr-docs], especially the [feature overview][rr-feature-overview] and the [tutorial][rr-tutorial].
|
|
317
|
+
|
|
318
|
+
**New APIs**
|
|
319
|
+
|
|
320
|
+
- Create your router with `createMemoryRouter`/`createBrowserRouter`/`createHashRouter`
|
|
321
|
+
- Render your router with `<RouterProvider>`
|
|
322
|
+
- Load data with a Route `loader` and mutate with a Route `action`
|
|
323
|
+
- Handle errors with Route `errorElement`
|
|
324
|
+
- Submit data with the new `<Form>` component
|
|
325
|
+
- Perform in-page data loads and mutations with `useFetcher()`
|
|
326
|
+
- Defer non-critical data with `defer` and `Await`
|
|
327
|
+
- Manage scroll position with `<ScrollRestoration>`
|
|
328
|
+
|
|
329
|
+
**New Features**
|
|
330
|
+
|
|
331
|
+
- Perform path-relative navigations with `<Link relative="path">` (#9160)
|
|
332
|
+
|
|
333
|
+
**Bug Fixes**
|
|
334
|
+
|
|
335
|
+
- Path resolution is now trailing slash agnostic (#8861)
|
|
336
|
+
- `useLocation` returns the scoped location inside a `<Routes location>` component (#9094)
|
|
337
|
+
- respect the `<Link replace>` prop if it is defined (#8779)
|
|
338
|
+
|
|
339
|
+
**Updated Dependencies**
|
|
340
|
+
|
|
341
|
+
- `react-router@6.4.0`
|
|
342
|
+
|
|
343
|
+
[rr-docs]: https://reactrouter.com
|
|
344
|
+
[rr-feature-overview]: https://reactrouter.com/start/overview
|
|
345
|
+
[rr-tutorial]: https://reactrouter.com/start/tutorial
|
package/{LICENSE → LICENSE.md}
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) React Training
|
|
3
|
+
Copyright (c) React Training LLC 2015-2019
|
|
4
|
+
Copyright (c) Remix Software Inc. 2020-2021
|
|
5
|
+
Copyright (c) Shopify Inc. 2022-2023
|
|
4
6
|
|
|
5
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
8
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,37 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# React Router DOM
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Using [npm](https://www.npmjs.com/):
|
|
8
|
-
|
|
9
|
-
$ npm install --save react-router-dom
|
|
10
|
-
|
|
11
|
-
Then with a module bundler like [webpack](https://webpack.github.io/), use as you would anything else:
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
// using ES6 modules
|
|
15
|
-
import { BrowserRouter, Route, Link } from "react-router-dom";
|
|
16
|
-
|
|
17
|
-
// using CommonJS modules
|
|
18
|
-
const BrowserRouter = require("react-router-dom").BrowserRouter;
|
|
19
|
-
const Route = require("react-router-dom").Route;
|
|
20
|
-
const Link = require("react-router-dom").Link;
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
The UMD build is also available on [unpkg](https://unpkg.com):
|
|
24
|
-
|
|
25
|
-
```html
|
|
26
|
-
<script src="https://unpkg.com/react-router-dom/umd/react-router-dom.min.js"></script>
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
You can find the library on `window.ReactRouterDOM`.
|
|
30
|
-
|
|
31
|
-
## Issues
|
|
32
|
-
|
|
33
|
-
If you find a bug, please file an issue on [our issue tracker on GitHub](https://github.com/ReactTraining/react-router/issues).
|
|
34
|
-
|
|
35
|
-
## Credits
|
|
36
|
-
|
|
37
|
-
React Router is built and maintained by [React Training](https://reacttraining.com).
|
|
3
|
+
The `react-router-dom` package contains bindings for using [React
|
|
4
|
+
Router](https://github.com/remix-run/react-router) in web applications.
|
|
5
|
+
Please see [the Getting Started guide](https://reactrouter.com/en/main/start/tutorial) for more information on how to get started with React Router.
|
package/dist/dom.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { FormEncType, HTMLFormMethod, RelativeRoutingType } from "@remix-run/router";
|
|
2
|
+
export declare const defaultMethod: HTMLFormMethod;
|
|
3
|
+
export declare function isHtmlElement(object: any): object is HTMLElement;
|
|
4
|
+
export declare function isButtonElement(object: any): object is HTMLButtonElement;
|
|
5
|
+
export declare function isFormElement(object: any): object is HTMLFormElement;
|
|
6
|
+
export declare function isInputElement(object: any): object is HTMLInputElement;
|
|
7
|
+
declare type LimitedMouseEvent = Pick<MouseEvent, "button" | "metaKey" | "altKey" | "ctrlKey" | "shiftKey">;
|
|
8
|
+
export declare function shouldProcessLinkClick(event: LimitedMouseEvent, target?: string): boolean;
|
|
9
|
+
export declare type ParamKeyValuePair = [string, string];
|
|
10
|
+
export declare type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a URLSearchParams object using the given initializer.
|
|
13
|
+
*
|
|
14
|
+
* This is identical to `new URLSearchParams(init)` except it also
|
|
15
|
+
* supports arrays as values in the object form of the initializer
|
|
16
|
+
* instead of just strings. This is convenient when you need multiple
|
|
17
|
+
* values for a given key, but don't want to use an array initializer.
|
|
18
|
+
*
|
|
19
|
+
* For example, instead of:
|
|
20
|
+
*
|
|
21
|
+
* let searchParams = new URLSearchParams([
|
|
22
|
+
* ['sort', 'name'],
|
|
23
|
+
* ['sort', 'price']
|
|
24
|
+
* ]);
|
|
25
|
+
*
|
|
26
|
+
* you can do:
|
|
27
|
+
*
|
|
28
|
+
* let searchParams = createSearchParams({
|
|
29
|
+
* sort: ['name', 'price']
|
|
30
|
+
* });
|
|
31
|
+
*/
|
|
32
|
+
export declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
|
|
33
|
+
export declare function getSearchParamsForLocation(locationSearch: string, defaultSearchParams: URLSearchParams | null): URLSearchParams;
|
|
34
|
+
export interface SubmitOptions {
|
|
35
|
+
/**
|
|
36
|
+
* The HTTP method used to submit the form. Overrides `<form method>`.
|
|
37
|
+
* Defaults to "GET".
|
|
38
|
+
*/
|
|
39
|
+
method?: HTMLFormMethod;
|
|
40
|
+
/**
|
|
41
|
+
* The action URL path used to submit the form. Overrides `<form action>`.
|
|
42
|
+
* Defaults to the path of the current route.
|
|
43
|
+
*/
|
|
44
|
+
action?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The action URL used to submit the form. Overrides `<form encType>`.
|
|
47
|
+
* Defaults to "application/x-www-form-urlencoded".
|
|
48
|
+
*/
|
|
49
|
+
encType?: FormEncType;
|
|
50
|
+
/**
|
|
51
|
+
* Set `true` to replace the current entry in the browser's history stack
|
|
52
|
+
* instead of creating a new one (i.e. stay on "the same page"). Defaults
|
|
53
|
+
* to `false`.
|
|
54
|
+
*/
|
|
55
|
+
replace?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Determines whether the form action is relative to the route hierarchy or
|
|
58
|
+
* the pathname. Use this if you want to opt out of navigating the route
|
|
59
|
+
* hierarchy and want to instead route based on /-delimited URL segments
|
|
60
|
+
*/
|
|
61
|
+
relative?: RelativeRoutingType;
|
|
62
|
+
/**
|
|
63
|
+
* In browser-based environments, prevent resetting scroll after this
|
|
64
|
+
* navigation when using the <ScrollRestoration> component
|
|
65
|
+
*/
|
|
66
|
+
preventScrollReset?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export declare function getFormSubmissionInfo(target: HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | {
|
|
69
|
+
[name: string]: string;
|
|
70
|
+
} | null, options: SubmitOptions, basename: string): {
|
|
71
|
+
action: string | null;
|
|
72
|
+
method: string;
|
|
73
|
+
encType: string;
|
|
74
|
+
formData: FormData;
|
|
75
|
+
};
|
|
76
|
+
export {};
|