react-router-dom 6.14.1 → 6.14.2-pre.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 +11 -0
- package/dist/dom.d.ts +4 -0
- package/dist/index.d.ts +19 -13
- package/dist/index.js +29 -8
- package/dist/index.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/react-router-dom.development.js +28 -7
- package/dist/react-router-dom.development.js.map +1 -1
- package/dist/react-router-dom.production.min.js +2 -2
- package/dist/react-router-dom.production.min.js.map +1 -1
- package/dist/server.js +6 -1
- package/dist/server.mjs +6 -1
- package/dist/umd/react-router-dom.development.js +29 -8
- package/dist/umd/react-router-dom.development.js.map +1 -1
- package/dist/umd/react-router-dom.production.min.js +2 -2
- package/dist/umd/react-router-dom.production.min.js.map +1 -1
- package/package.json +3 -3
- package/server.js +6 -1
- package/server.mjs +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# `react-router-dom`
|
|
2
2
|
|
|
3
|
+
## 6.14.2-pre.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add missing `<Form state>` prop to populate `history.state` on submission navigations ([#10630](https://github.com/remix-run/react-router/pull/10630))
|
|
8
|
+
- Properly decode element id when emulating hash scrolling via `<ScrollRestoration>` ([#10682](https://github.com/remix-run/react-router/pull/10682))
|
|
9
|
+
- Support proper hydration of `Error` subclasses such as `ReferenceError`/`TypeError` ([#10633](https://github.com/remix-run/react-router/pull/10633))
|
|
10
|
+
- Updated dependencies:
|
|
11
|
+
- `@remix-run/router@1.7.2-pre.0`
|
|
12
|
+
- `react-router@6.14.2-pre.0`
|
|
13
|
+
|
|
3
14
|
## 6.14.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/dom.d.ts
CHANGED
|
@@ -62,6 +62,10 @@ export interface SubmitOptions {
|
|
|
62
62
|
* to `false`.
|
|
63
63
|
*/
|
|
64
64
|
replace?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* State object to add to the history stack entry for this navigation
|
|
67
|
+
*/
|
|
68
|
+
state?: any;
|
|
65
69
|
/**
|
|
66
70
|
* Determines whether the form action is relative to the route hierarchy or
|
|
67
71
|
* the pathname. Use this if you want to opt out of navigating the route
|
package/dist/index.d.ts
CHANGED
|
@@ -94,7 +94,7 @@ export interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "c
|
|
|
94
94
|
* A <Link> wrapper that knows if it's "active" or not.
|
|
95
95
|
*/
|
|
96
96
|
export declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
97
|
-
export interface
|
|
97
|
+
export interface FetcherFormProps extends React.FormHTMLAttributes<HTMLFormElement> {
|
|
98
98
|
/**
|
|
99
99
|
* The HTTP verb to use when the form is submit. Supports "get", "post",
|
|
100
100
|
* "put", "delete", "patch".
|
|
@@ -109,16 +109,6 @@ export interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {
|
|
|
109
109
|
* Normal `<form action>` but supports React Router's relative paths.
|
|
110
110
|
*/
|
|
111
111
|
action?: string;
|
|
112
|
-
/**
|
|
113
|
-
* Forces a full document navigation instead of a fetch.
|
|
114
|
-
*/
|
|
115
|
-
reloadDocument?: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Replaces the current entry in the browser history stack when the form
|
|
118
|
-
* navigates. Use this if you don't want the user to be able to click "back"
|
|
119
|
-
* to the page with the form on it.
|
|
120
|
-
*/
|
|
121
|
-
replace?: boolean;
|
|
122
112
|
/**
|
|
123
113
|
* Determines whether the form action is relative to the route hierarchy or
|
|
124
114
|
* the pathname. Use this if you want to opt out of navigating the route
|
|
@@ -136,6 +126,22 @@ export interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {
|
|
|
136
126
|
*/
|
|
137
127
|
onSubmit?: React.FormEventHandler<HTMLFormElement>;
|
|
138
128
|
}
|
|
129
|
+
export interface FormProps extends FetcherFormProps {
|
|
130
|
+
/**
|
|
131
|
+
* Forces a full document navigation instead of a fetch.
|
|
132
|
+
*/
|
|
133
|
+
reloadDocument?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Replaces the current entry in the browser history stack when the form
|
|
136
|
+
* navigates. Use this if you don't want the user to be able to click "back"
|
|
137
|
+
* to the page with the form on it.
|
|
138
|
+
*/
|
|
139
|
+
replace?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* State object to add to the history stack entry for this navigation
|
|
142
|
+
*/
|
|
143
|
+
state?: any;
|
|
144
|
+
}
|
|
139
145
|
/**
|
|
140
146
|
* A `@remix-run/router`-aware `<form>`. It behaves like a normal form except
|
|
141
147
|
* that the interaction with the server is with `fetch` instead of new document
|
|
@@ -197,7 +203,7 @@ export interface SubmitFunction {
|
|
|
197
203
|
* Submits a fetcher `<form>` to the server without reloading the page.
|
|
198
204
|
*/
|
|
199
205
|
export interface FetcherSubmitFunction {
|
|
200
|
-
(target: SubmitTarget, options?: Omit<SubmitOptions, "replace">): void;
|
|
206
|
+
(target: SubmitTarget, options?: Omit<SubmitOptions, "replace" | "state">): void;
|
|
201
207
|
}
|
|
202
208
|
/**
|
|
203
209
|
* Returns a function that may be used to programmatically submit a form (or
|
|
@@ -207,7 +213,7 @@ export declare function useSubmit(): SubmitFunction;
|
|
|
207
213
|
export declare function useFormAction(action?: string, { relative }?: {
|
|
208
214
|
relative?: RelativeRoutingType;
|
|
209
215
|
}): string;
|
|
210
|
-
declare function createFetcherForm(fetcherKey: string, routeId: string): React.ForwardRefExoticComponent<
|
|
216
|
+
declare function createFetcherForm(fetcherKey: string, routeId: string): React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
|
|
211
217
|
export type FetcherWithComponents<TData> = Fetcher<TData> & {
|
|
212
218
|
Form: ReturnType<typeof createFetcherForm>;
|
|
213
219
|
submit: FetcherSubmitFunction;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* React Router DOM v6.14.
|
|
2
|
+
* React Router DOM v6.14.2-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -203,7 +203,7 @@ function getFormSubmissionInfo(target, basename) {
|
|
|
203
203
|
|
|
204
204
|
const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset"],
|
|
205
205
|
_excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "children"],
|
|
206
|
-
_excluded3 = ["reloadDocument", "replace", "method", "action", "onSubmit", "submit", "relative", "preventScrollReset"];
|
|
206
|
+
_excluded3 = ["reloadDocument", "replace", "state", "method", "action", "onSubmit", "submit", "relative", "preventScrollReset"];
|
|
207
207
|
function createBrowserRouter(routes, opts) {
|
|
208
208
|
return createRouter({
|
|
209
209
|
basename: opts == null ? void 0 : opts.basename,
|
|
@@ -252,11 +252,29 @@ function deserializeErrors(errors) {
|
|
|
252
252
|
if (val && val.__type === "RouteErrorResponse") {
|
|
253
253
|
serialized[key] = new ErrorResponse(val.status, val.statusText, val.data, val.internal === true);
|
|
254
254
|
} else if (val && val.__type === "Error") {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
255
|
+
// Attempt to reconstruct the right type of Error (i.e., ReferenceError)
|
|
256
|
+
if (val.__subType) {
|
|
257
|
+
let ErrorConstructor = window[val.__subType];
|
|
258
|
+
if (typeof ErrorConstructor === "function") {
|
|
259
|
+
try {
|
|
260
|
+
// @ts-expect-error
|
|
261
|
+
let error = new ErrorConstructor(val.message);
|
|
262
|
+
// Wipe away the client-side stack trace. Nothing to fill it in with
|
|
263
|
+
// because we don't serialize SSR stack traces for security reasons
|
|
264
|
+
error.stack = "";
|
|
265
|
+
serialized[key] = error;
|
|
266
|
+
} catch (e) {
|
|
267
|
+
// no-op - fall through and create a normal Error
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (serialized[key] == null) {
|
|
272
|
+
let error = new Error(val.message);
|
|
273
|
+
// Wipe away the client-side stack trace. Nothing to fill it in with
|
|
274
|
+
// because we don't serialize SSR stack traces for security reasons
|
|
275
|
+
error.stack = "";
|
|
276
|
+
serialized[key] = error;
|
|
277
|
+
}
|
|
260
278
|
} else {
|
|
261
279
|
serialized[key] = val;
|
|
262
280
|
}
|
|
@@ -560,6 +578,7 @@ const FormImpl = /*#__PURE__*/React.forwardRef((_ref6, forwardedRef) => {
|
|
|
560
578
|
let {
|
|
561
579
|
reloadDocument,
|
|
562
580
|
replace,
|
|
581
|
+
state,
|
|
563
582
|
method = defaultMethod,
|
|
564
583
|
action,
|
|
565
584
|
onSubmit,
|
|
@@ -581,6 +600,7 @@ const FormImpl = /*#__PURE__*/React.forwardRef((_ref6, forwardedRef) => {
|
|
|
581
600
|
submit(submitter || event.currentTarget, {
|
|
582
601
|
method: submitMethod,
|
|
583
602
|
replace,
|
|
603
|
+
state,
|
|
584
604
|
relative,
|
|
585
605
|
preventScrollReset
|
|
586
606
|
});
|
|
@@ -733,6 +753,7 @@ function useSubmit() {
|
|
|
733
753
|
formMethod: options.method || method,
|
|
734
754
|
formEncType: options.encType || encType,
|
|
735
755
|
replace: options.replace,
|
|
756
|
+
state: options.state,
|
|
736
757
|
fromRouteId: currentRouteId
|
|
737
758
|
});
|
|
738
759
|
}, [router, basename, currentRouteId]);
|
|
@@ -961,7 +982,7 @@ function useScrollRestoration(_temp3) {
|
|
|
961
982
|
}
|
|
962
983
|
// try to scroll to the hash
|
|
963
984
|
if (location.hash) {
|
|
964
|
-
let el = document.getElementById(location.hash.slice(1));
|
|
985
|
+
let el = document.getElementById(decodeURIComponent(location.hash.slice(1)));
|
|
965
986
|
if (el) {
|
|
966
987
|
el.scrollIntoView();
|
|
967
988
|
return;
|