react-router-dom 6.12.1 → 6.13.0-pre.1
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 +39 -0
- package/dist/index.d.ts +9 -6
- package/dist/index.js +20 -12
- package/dist/index.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/react-router-dom.development.js +20 -13
- 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/umd/react-router-dom.development.js +19 -12
- 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 +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# `react-router-dom`
|
|
2
2
|
|
|
3
|
+
## 6.13.0-pre.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Move [`React.startTransition`](https://react.dev/reference/react/startTransition) behind a [future flag](https://reactrouter.com/en/main/guides/api-development-strategy) to avoid issues with existing incompatible `Suspense` usages. We recommend folks adopting this flag to be better compatible with React concurrent mode, but if you run into issues you can continue without the use of `startTransition` until v7. Issues usually boils down to creating net-new promises during the render cycle, so if you run into issues you should either lift your promise creation out of the render cycle or put it behind a `useMemo`. ([#10596](https://github.com/remix-run/react-router/pull/10596))
|
|
8
|
+
|
|
9
|
+
Existing behavior will no longer include `React.startTransition`:
|
|
10
|
+
|
|
11
|
+
```jsx
|
|
12
|
+
<BrowserRouter>
|
|
13
|
+
<Routes>{/*...*/}</Routes>
|
|
14
|
+
</BrowserRouter>
|
|
15
|
+
|
|
16
|
+
<RouterProvider router={router} />
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
If you wish to enable `React.startTransition`, pass the future flag to your component:
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
<BrowserRouter future={{ v7_startTransition: true }}>
|
|
23
|
+
<Routes>{/*...*/}</Routes>
|
|
24
|
+
</BrowserRouter>
|
|
25
|
+
|
|
26
|
+
<RouterProvider router={router} future={{ v7_startTransition: true }}/>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies:
|
|
32
|
+
- `react-router@6.13.0-pre.1`
|
|
33
|
+
|
|
34
|
+
## 6.12.2-pre.0
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Work around webpack/terser `React.startTransition` minification bug in production mode ([`2f79bcef`](https://github.com/remix-run/react-router/commit/2f79bcef5f396943cf95d0d23fbd67df9b8e17a6))
|
|
39
|
+
- Updated dependencies:
|
|
40
|
+
- `react-router@6.12.2-pre.0`
|
|
41
|
+
|
|
3
42
|
## 6.12.1
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* you'll need to update the rollup config for react-router-dom-v5-compat.
|
|
4
4
|
*/
|
|
5
5
|
import * as React from "react";
|
|
6
|
-
import type { NavigateOptions, RelativeRoutingType, RouteObject, To } from "react-router";
|
|
7
|
-
import type { Fetcher, FormEncType, FormMethod, FutureConfig, GetScrollRestorationKeyFunction, History, HTMLFormMethod, HydrationState, Router as RemixRouter, V7_FormMethod } from "@remix-run/router";
|
|
6
|
+
import type { FutureConfig, NavigateOptions, RelativeRoutingType, RouteObject, To } from "react-router";
|
|
7
|
+
import type { Fetcher, FormEncType, FormMethod, FutureConfig as RouterFutureConfig, GetScrollRestorationKeyFunction, History, HTMLFormMethod, HydrationState, Router as RemixRouter, V7_FormMethod } from "@remix-run/router";
|
|
8
8
|
import type { SubmitOptions, ParamKeyValuePair, URLSearchParamsInit } from "./dom";
|
|
9
9
|
import { createSearchParams } from "./dom";
|
|
10
10
|
export type { FormEncType, FormMethod, GetScrollRestorationKeyFunction, ParamKeyValuePair, SubmitOptions, URLSearchParamsInit, V7_FormMethod, };
|
|
@@ -18,7 +18,7 @@ declare global {
|
|
|
18
18
|
}
|
|
19
19
|
interface DOMRouterOpts {
|
|
20
20
|
basename?: string;
|
|
21
|
-
future?: Partial<Omit<
|
|
21
|
+
future?: Partial<Omit<RouterFutureConfig, "v7_prependBasename">>;
|
|
22
22
|
hydrationData?: HydrationState;
|
|
23
23
|
window?: Window;
|
|
24
24
|
}
|
|
@@ -27,25 +27,28 @@ export declare function createHashRouter(routes: RouteObject[], opts?: DOMRouter
|
|
|
27
27
|
export interface BrowserRouterProps {
|
|
28
28
|
basename?: string;
|
|
29
29
|
children?: React.ReactNode;
|
|
30
|
+
future?: FutureConfig;
|
|
30
31
|
window?: Window;
|
|
31
32
|
}
|
|
32
33
|
/**
|
|
33
34
|
* A `<Router>` for use in web browsers. Provides the cleanest URLs.
|
|
34
35
|
*/
|
|
35
|
-
export declare function BrowserRouter({ basename, children, window, }: BrowserRouterProps): JSX.Element;
|
|
36
|
+
export declare function BrowserRouter({ basename, children, future, window, }: BrowserRouterProps): JSX.Element;
|
|
36
37
|
export interface HashRouterProps {
|
|
37
38
|
basename?: string;
|
|
38
39
|
children?: React.ReactNode;
|
|
40
|
+
future?: FutureConfig;
|
|
39
41
|
window?: Window;
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* A `<Router>` for use in web browsers. Stores the location in the hash
|
|
43
45
|
* portion of the URL so it is not sent to the server.
|
|
44
46
|
*/
|
|
45
|
-
export declare function HashRouter({ basename, children, window }: HashRouterProps): JSX.Element;
|
|
47
|
+
export declare function HashRouter({ basename, children, future, window, }: HashRouterProps): JSX.Element;
|
|
46
48
|
export interface HistoryRouterProps {
|
|
47
49
|
basename?: string;
|
|
48
50
|
children?: React.ReactNode;
|
|
51
|
+
future?: FutureConfig;
|
|
49
52
|
history: History;
|
|
50
53
|
}
|
|
51
54
|
/**
|
|
@@ -54,7 +57,7 @@ export interface HistoryRouterProps {
|
|
|
54
57
|
* two versions of the history library to your bundles unless you use the same
|
|
55
58
|
* version of the history library that React Router uses internally.
|
|
56
59
|
*/
|
|
57
|
-
declare function HistoryRouter({ basename, children, history }: HistoryRouterProps): JSX.Element;
|
|
60
|
+
declare function HistoryRouter({ basename, children, future, history, }: HistoryRouterProps): JSX.Element;
|
|
58
61
|
declare namespace HistoryRouter {
|
|
59
62
|
var displayName: string;
|
|
60
63
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* React Router DOM v6.
|
|
2
|
+
* React Router DOM v6.13.0-pre.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
|
-
import { UNSAFE_mapRouteProperties, Router, UNSAFE_NavigationContext, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, useNavigate, createPath, UNSAFE_useRouteId, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_DataRouterContext } from 'react-router';
|
|
12
|
+
import { UNSAFE_mapRouteProperties, UNSAFE_startTransitionImpl, Router, UNSAFE_NavigationContext, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, useNavigate, createPath, UNSAFE_useRouteId, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_DataRouterContext } from 'react-router';
|
|
13
13
|
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, UNSAFE_useRouteId, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes } from 'react-router';
|
|
14
14
|
import { stripBasename, createRouter, createBrowserHistory, createHashHistory, ErrorResponse, UNSAFE_warning, UNSAFE_invariant, joinPaths } from '@remix-run/router';
|
|
15
15
|
|
|
@@ -244,10 +244,6 @@ function deserializeErrors(errors) {
|
|
|
244
244
|
}
|
|
245
245
|
return serialized;
|
|
246
246
|
}
|
|
247
|
-
// Webpack + React 17 fails to compile on the usage of `React.startTransition` or
|
|
248
|
-
// `React["startTransition"]` even if it's behind a feature detection of
|
|
249
|
-
// `"startTransition" in React`. Moving this to a constant avoids the issue :/
|
|
250
|
-
const START_TRANSITION = "startTransition";
|
|
251
247
|
/**
|
|
252
248
|
* A `<Router>` for use in web browsers. Provides the cleanest URLs.
|
|
253
249
|
*/
|
|
@@ -255,6 +251,7 @@ function BrowserRouter(_ref) {
|
|
|
255
251
|
let {
|
|
256
252
|
basename,
|
|
257
253
|
children,
|
|
254
|
+
future,
|
|
258
255
|
window
|
|
259
256
|
} = _ref;
|
|
260
257
|
let historyRef = React.useRef();
|
|
@@ -269,9 +266,12 @@ function BrowserRouter(_ref) {
|
|
|
269
266
|
action: history.action,
|
|
270
267
|
location: history.location
|
|
271
268
|
});
|
|
269
|
+
let {
|
|
270
|
+
v7_startTransition
|
|
271
|
+
} = future || {};
|
|
272
272
|
let setState = React.useCallback(newState => {
|
|
273
|
-
|
|
274
|
-
}, [setStateImpl]);
|
|
273
|
+
v7_startTransition && UNSAFE_startTransitionImpl ? UNSAFE_startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
|
|
274
|
+
}, [setStateImpl, v7_startTransition]);
|
|
275
275
|
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
276
276
|
return /*#__PURE__*/React.createElement(Router, {
|
|
277
277
|
basename: basename,
|
|
@@ -289,6 +289,7 @@ function HashRouter(_ref2) {
|
|
|
289
289
|
let {
|
|
290
290
|
basename,
|
|
291
291
|
children,
|
|
292
|
+
future,
|
|
292
293
|
window
|
|
293
294
|
} = _ref2;
|
|
294
295
|
let historyRef = React.useRef();
|
|
@@ -303,9 +304,12 @@ function HashRouter(_ref2) {
|
|
|
303
304
|
action: history.action,
|
|
304
305
|
location: history.location
|
|
305
306
|
});
|
|
307
|
+
let {
|
|
308
|
+
v7_startTransition
|
|
309
|
+
} = future || {};
|
|
306
310
|
let setState = React.useCallback(newState => {
|
|
307
|
-
|
|
308
|
-
}, [setStateImpl]);
|
|
311
|
+
v7_startTransition && UNSAFE_startTransitionImpl ? UNSAFE_startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
|
|
312
|
+
}, [setStateImpl, v7_startTransition]);
|
|
309
313
|
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
310
314
|
return /*#__PURE__*/React.createElement(Router, {
|
|
311
315
|
basename: basename,
|
|
@@ -325,15 +329,19 @@ function HistoryRouter(_ref3) {
|
|
|
325
329
|
let {
|
|
326
330
|
basename,
|
|
327
331
|
children,
|
|
332
|
+
future,
|
|
328
333
|
history
|
|
329
334
|
} = _ref3;
|
|
330
335
|
let [state, setStateImpl] = React.useState({
|
|
331
336
|
action: history.action,
|
|
332
337
|
location: history.location
|
|
333
338
|
});
|
|
339
|
+
let {
|
|
340
|
+
v7_startTransition
|
|
341
|
+
} = future || {};
|
|
334
342
|
let setState = React.useCallback(newState => {
|
|
335
|
-
|
|
336
|
-
}, [setStateImpl]);
|
|
343
|
+
v7_startTransition && UNSAFE_startTransitionImpl ? UNSAFE_startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
|
|
344
|
+
}, [setStateImpl, v7_startTransition]);
|
|
337
345
|
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
|
|
338
346
|
return /*#__PURE__*/React.createElement(Router, {
|
|
339
347
|
basename: basename,
|