Skip to content

Commit 70d0aa1

Browse files
committed
Merge branch 'release-next'
2 parents 4b494b9 + 13fb25a commit 70d0aa1

29 files changed

+758
-366
lines changed

contributors.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
- jonkoops
113113
- jrakotoharisoa
114114
- kachun333
115+
- juanpprieto
115116
- kantuni
116117
- kark
117118
- KAROTT7

docs/route/should-revalidate.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@ new: true
55

66
# `shouldRevalidate`
77

8+
<details>
9+
<summary>Type declaration</summary>
10+
11+
```ts
12+
interface ShouldRevalidateFunction {
13+
(args: ShouldRevalidateFunctionArgs): boolean;
14+
}
15+
16+
interface ShouldRevalidateFunctionArgs {
17+
currentUrl: URL;
18+
currentParams: AgnosticDataRouteMatch["params"];
19+
nextUrl: URL;
20+
nextParams: AgnosticDataRouteMatch["params"];
21+
formMethod?: Submission["formMethod"];
22+
formAction?: Submission["formAction"];
23+
formEncType?: Submission["formEncType"];
24+
text?: Submission["text"];
25+
formData?: Submission["formData"];
26+
json?: Submission["json"];
27+
actionResult?: any;
28+
defaultShouldRevalidate: boolean;
29+
}
30+
```
31+
32+
</details>
33+
834
This function allows you opt-out of revalidation for a route's loader as an optimization.
935

1036
<docs-warning>This feature only works if using a data router, see [Picking a Router][pickingarouter]</docs-warning>
@@ -53,27 +79,6 @@ Note that this is only for data that has already been loaded, is currently rende
5379

5480
<docs-warning>Using this API risks your UI getting out of sync with your data, use with caution!</docs-warning>
5581

56-
## Type Declaration
57-
58-
```ts
59-
interface ShouldRevalidateFunction {
60-
(args: {
61-
currentUrl: URL;
62-
currentParams: AgnosticDataRouteMatch["params"];
63-
nextUrl: URL;
64-
nextParams: AgnosticDataRouteMatch["params"];
65-
formMethod?: Submission["formMethod"];
66-
formAction?: Submission["formAction"];
67-
formEncType?: Submission["formEncType"];
68-
formData?: Submission["formData"];
69-
json?: Submission["json"];
70-
text?: Submission["text"];
71-
actionResult?: DataResult;
72-
defaultShouldRevalidate: boolean;
73-
}): boolean;
74-
}
75-
```
76-
7782
[action]: ./action
7883
[form]: ../components/form
7984
[fetcher]: ../hooks/use-fetcher

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
},
111111
"filesize": {
112112
"packages/router/dist/router.umd.min.js": {
113-
"none": "47.5 kB"
113+
"none": "47.3 kB"
114114
},
115115
"packages/react-router/dist/react-router.production.min.js": {
116116
"none": "13.9 kB"

packages/react-router-dom-v5-compat/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# `react-router-dom-v5-compat`
22

3+
## 6.16.0
4+
5+
### Minor Changes
6+
7+
- Updated dependencies:
8+
9+
10+
311
## 6.15.0
412

513
### Minor Changes

packages/react-router-dom-v5-compat/index.ts

Lines changed: 68 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -47,67 +47,72 @@
4747
* deprecate the deep require if we wanted to avoid the duplication here.
4848
*/
4949
export type {
50-
BrowserRouterProps,
51-
Hash,
52-
HashRouterProps,
53-
HistoryRouterProps,
54-
LinkProps,
55-
Location,
56-
Path,
57-
To,
58-
MemoryRouterProps,
59-
NavigateFunction,
60-
NavigateOptions,
61-
NavigateProps,
62-
Navigator,
63-
NavLinkProps,
64-
OutletProps,
65-
Params,
66-
ParamParseKey,
67-
PathMatch,
68-
RouteMatch,
69-
RouteObject,
70-
RouteProps,
71-
PathRouteProps,
72-
LayoutRouteProps,
73-
IndexRouteProps,
74-
RouterProps,
75-
Pathname,
76-
Search,
77-
RoutesProps,
78-
ParamKeyValuePair,
79-
URLSearchParamsInit,
80-
// New stuff from RR 6.4
8150
ActionFunction,
8251
ActionFunctionArgs,
8352
AwaitProps,
84-
unstable_Blocker,
85-
unstable_BlockerFunction,
53+
BrowserRouterProps,
8654
DataRouteMatch,
8755
DataRouteObject,
56+
ErrorResponse,
8857
Fetcher,
8958
FetcherWithComponents,
9059
FormEncType,
9160
FormMethod,
9261
FormProps,
9362
GetScrollRestorationKeyFunction,
63+
Hash,
64+
HashRouterProps,
65+
HistoryRouterProps,
9466
IndexRouteObject,
67+
IndexRouteProps,
9568
JsonFunction,
69+
LayoutRouteProps,
70+
LinkProps,
9671
LoaderFunction,
9772
LoaderFunctionArgs,
73+
Location,
74+
MemoryRouterProps,
75+
NavLinkProps,
76+
NavigateFunction,
77+
NavigateOptions,
78+
NavigateProps,
9879
Navigation,
80+
Navigator,
9981
NonIndexRouteObject,
82+
OutletProps,
83+
ParamKeyValuePair,
84+
ParamParseKey,
85+
Params,
86+
Path,
87+
PathMatch,
10088
PathPattern,
89+
PathRouteProps,
90+
Pathname,
10191
RedirectFunction,
10292
RelativeRoutingType,
93+
RouteMatch,
94+
RouteObject,
95+
RouteProps,
96+
RouterProps,
10397
RouterProviderProps,
98+
RoutesProps,
10499
ScrollRestorationProps,
100+
Search,
105101
ShouldRevalidateFunction,
102+
ShouldRevalidateFunctionArgs,
106103
SubmitFunction,
107104
SubmitOptions,
105+
To,
106+
URLSearchParamsInit,
107+
UIMatch,
108+
unstable_Blocker,
109+
unstable_BlockerFunction,
108110
} from "./react-router-dom";
109111
export {
112+
AbortedDeferredError,
113+
Await,
110114
BrowserRouter,
115+
Form,
111116
HashRouter,
112117
Link,
113118
MemoryRouter,
@@ -117,69 +122,65 @@ export {
117122
Outlet,
118123
Route,
119124
Router,
125+
RouterProvider,
120126
Routes,
127+
ScrollRestoration,
128+
UNSAFE_DataRouterContext,
129+
UNSAFE_DataRouterStateContext,
121130
UNSAFE_LocationContext,
122131
UNSAFE_NavigationContext,
123132
UNSAFE_RouteContext,
133+
UNSAFE_useRouteId,
134+
UNSAFE_useScrollRestoration,
135+
createBrowserRouter,
136+
createHashRouter,
137+
createMemoryRouter,
124138
createPath,
125139
createRoutesFromChildren,
140+
createRoutesFromElements,
126141
createSearchParams,
142+
defer,
127143
generatePath,
144+
isRouteErrorResponse,
145+
json,
128146
matchPath,
129147
matchRoutes,
130148
parsePath,
149+
redirect,
150+
redirectDocument,
131151
renderMatches,
132152
resolvePath,
133153
unstable_HistoryRouter,
154+
unstable_useBlocker,
155+
unstable_usePrompt,
156+
useActionData,
157+
useAsyncError,
158+
useAsyncValue,
159+
useBeforeUnload,
160+
useFetcher,
161+
useFetchers,
162+
useFormAction,
134163
useHref,
135164
useInRouterContext,
136165
useLinkClickHandler,
166+
useLoaderData,
137167
useLocation,
138168
useMatch,
169+
useMatches,
139170
useNavigate,
171+
useNavigation,
140172
useNavigationType,
141173
useOutlet,
142174
useOutletContext,
143175
useParams,
144176
useResolvedPath,
145-
useRoutes,
146-
useSearchParams,
147-
// New stuff from 6.4
148-
AbortedDeferredError,
149-
Await,
150-
RouterProvider,
151-
ScrollRestoration,
152-
createBrowserRouter,
153-
createHashRouter,
154-
createMemoryRouter,
155-
createRoutesFromElements,
156-
defer,
157-
isRouteErrorResponse,
158-
Form,
159-
json,
160-
redirect,
161-
redirectDocument,
162-
useActionData,
163-
useAsyncError,
164-
useAsyncValue,
165-
useBeforeUnload,
166-
unstable_useBlocker,
167-
useFetcher,
168-
useFetchers,
169-
useFormAction,
170-
useLoaderData,
171-
useMatches,
172-
useNavigation,
173-
unstable_usePrompt,
174177
useRevalidator,
175178
useRouteError,
176179
useRouteLoaderData,
180+
useRoutes,
181+
useSearchParams,
177182
useSubmit,
178-
UNSAFE_DataRouterContext,
179-
UNSAFE_DataRouterStateContext,
180-
UNSAFE_useScrollRestoration,
181-
UNSAFE_useRouteId,
182183
} from "./react-router-dom";
183184

184185
export type { StaticRouterProps } from "./lib/components";
185-
export { CompatRouter, CompatRoute, StaticRouter } from "./lib/components";
186+
export { CompatRoute, CompatRouter, StaticRouter } from "./lib/components";

packages/react-router-dom-v5-compat/lib/components.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ export interface StaticRouterProps {
6666
location: Partial<Location> | string;
6767
}
6868

69+
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
70+
6971
/**
7072
* A <Router> that may not navigate to any other location. This is useful
7173
* on the server where there is no stateful UI.
@@ -93,11 +95,14 @@ export function StaticRouter({
9395
return typeof to === "string" ? to : createPath(to);
9496
},
9597
encodeLocation(to: To) {
96-
let path = typeof to === "string" ? parsePath(to) : to;
98+
let href = typeof to === "string" ? to : createPath(to);
99+
let encoded = ABSOLUTE_URL_REGEX.test(href)
100+
? new URL(href)
101+
: new URL(href, "http://localhost");
97102
return {
98-
pathname: path.pathname || "",
99-
search: path.search || "",
100-
hash: path.hash || "",
103+
pathname: encoded.pathname,
104+
search: encoded.search,
105+
hash: encoded.hash,
101106
};
102107
},
103108
push(to: To) {

packages/react-router-dom-v5-compat/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-router-dom-v5-compat",
3-
"version": "6.15.0",
3+
"version": "6.16.0",
44
"description": "Migration path to React Router v6 from v4/5",
55
"keywords": [
66
"react",
@@ -24,7 +24,7 @@
2424
"types": "./dist/index.d.ts",
2525
"dependencies": {
2626
"history": "^5.3.0",
27-
"react-router": "6.15.0"
27+
"react-router": "6.16.0"
2828
},
2929
"peerDependencies": {
3030
"react": ">=16.8",

packages/react-router-dom/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# `react-router-dom`
22

3+
## 6.16.0
4+
5+
### Minor Changes
6+
7+
- Updated dependencies:
8+
- `@remix-run/[email protected]`
9+
10+
11+
### Patch Changes
12+
13+
- Properly encode rendered URIs in server rendering to avoid hydration errors ([#10769](https://github.com/remix-run/react-router/pull/10769))
14+
315
## 6.15.0
416

517
### Minor Changes

0 commit comments

Comments
 (0)