@remix-run/router 1.6.3 → 1.7.0
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 +53 -0
- package/dist/history.d.ts +6 -6
- package/dist/router.cjs.js +378 -234
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.d.ts +69 -41
- package/dist/router.js +365 -229
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +378 -234
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +54 -28
- package/package.json +1 -1
- package/router.ts +501 -277
- package/utils.ts +44 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
+
## 1.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add support for `application/json` and `text/plain` encodings for `router.navigate`/`router.fetch` submissions. To leverage these encodings, pass your data in a `body` parameter and specify the desired `formEncType`: ([#10413](https://github.com/remix-run/react-router/pull/10413))
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
// By default, the encoding is "application/x-www-form-urlencoded"
|
|
11
|
+
router.navigate("/", {
|
|
12
|
+
formMethod: "post",
|
|
13
|
+
body: { key: "value" },
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
async function action({ request }) {
|
|
17
|
+
// await request.formData() => FormData instance with entry [key=value]
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
// Pass `formEncType` to opt-into a different encoding (json)
|
|
23
|
+
router.navigate("/", {
|
|
24
|
+
formMethod: "post",
|
|
25
|
+
formEncType: "application/json",
|
|
26
|
+
body: { key: "value" },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
async function action({ request }) {
|
|
30
|
+
// await request.json() => { key: "value" }
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
// Pass `formEncType` to opt-into a different encoding (text)
|
|
36
|
+
router.navigate("/", {
|
|
37
|
+
formMethod: "post",
|
|
38
|
+
formEncType: "text/plain",
|
|
39
|
+
body: "Text submission",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
async function action({ request }) {
|
|
43
|
+
// await request.text() => "Text submission"
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Call `window.history.pushState/replaceState` before updating React Router state (instead of after) so that `window.location` matches `useLocation` during synchronous React 17 rendering ([#10448](https://github.com/remix-run/react-router/pull/10448))
|
|
50
|
+
- ⚠️ However, generally apps should not be relying on `window.location` and should always reference `useLocation` when possible, as `window.location` will not be in sync 100% of the time (due to `popstate` events, concurrent mode, etc.)
|
|
51
|
+
- Strip `basename` from the `location` provided to `<ScrollRestoration getKey>` to match the `useLocation` behavior ([#10550](https://github.com/remix-run/react-router/pull/10550))
|
|
52
|
+
- Avoid calling `shouldRevalidate` for fetchers that have not yet completed a data load ([#10623](https://github.com/remix-run/react-router/pull/10623))
|
|
53
|
+
- Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573))
|
|
54
|
+
- Upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581))
|
|
55
|
+
|
|
3
56
|
## 1.6.3
|
|
4
57
|
|
|
5
58
|
### Patch Changes
|
package/dist/history.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export interface Listener {
|
|
|
84
84
|
* `history.push` or `history.replace`. May be either a URL or the pieces of a
|
|
85
85
|
* URL path.
|
|
86
86
|
*/
|
|
87
|
-
export
|
|
87
|
+
export type To = string | Partial<Path>;
|
|
88
88
|
/**
|
|
89
89
|
* A history is an interface to the navigation stack. The history serves as the
|
|
90
90
|
* source of truth for the current location, as well as provides a set of
|
|
@@ -161,8 +161,8 @@ export interface History {
|
|
|
161
161
|
* A user-supplied object that describes a location. Used when providing
|
|
162
162
|
* entries to `createMemoryHistory` via its `initialEntries` option.
|
|
163
163
|
*/
|
|
164
|
-
export
|
|
165
|
-
export
|
|
164
|
+
export type InitialEntry = string | Partial<Location>;
|
|
165
|
+
export type MemoryHistoryOptions = {
|
|
166
166
|
initialEntries?: InitialEntry[];
|
|
167
167
|
initialIndex?: number;
|
|
168
168
|
v5Compat?: boolean;
|
|
@@ -192,7 +192,7 @@ export declare function createMemoryHistory(options?: MemoryHistoryOptions): Mem
|
|
|
192
192
|
*/
|
|
193
193
|
export interface BrowserHistory extends UrlHistory {
|
|
194
194
|
}
|
|
195
|
-
export
|
|
195
|
+
export type BrowserHistoryOptions = UrlHistoryOptions;
|
|
196
196
|
/**
|
|
197
197
|
* Browser history stores the location in regular URLs. This is the standard for
|
|
198
198
|
* most web apps, but it requires some configuration on the server to ensure you
|
|
@@ -214,7 +214,7 @@ export declare function createBrowserHistory(options?: BrowserHistoryOptions): B
|
|
|
214
214
|
*/
|
|
215
215
|
export interface HashHistory extends UrlHistory {
|
|
216
216
|
}
|
|
217
|
-
export
|
|
217
|
+
export type HashHistoryOptions = UrlHistoryOptions;
|
|
218
218
|
/**
|
|
219
219
|
* Hash history stores the location in window.location.hash. This makes it ideal
|
|
220
220
|
* for situations where you don't want to send the location to the server for
|
|
@@ -244,7 +244,7 @@ export declare function createPath({ pathname, search, hash, }: Partial<Path>):
|
|
|
244
244
|
export declare function parsePath(path: string): Partial<Path>;
|
|
245
245
|
export interface UrlHistory extends History {
|
|
246
246
|
}
|
|
247
|
-
export
|
|
247
|
+
export type UrlHistoryOptions = {
|
|
248
248
|
window?: Window;
|
|
249
249
|
v5Compat?: boolean;
|
|
250
250
|
};
|