react-router 6.4.0-pre.4 → 6.4.0-pre.7
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 +21 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -19
- package/dist/index.js.map +1 -1
- package/dist/lib/components.d.ts +1 -1
- package/dist/lib/hooks.d.ts +1 -1
- package/dist/main.js +3 -3
- package/dist/react-router.development.js +17 -19
- package/dist/react-router.development.js.map +1 -1
- package/dist/react-router.production.min.js +2 -2
- package/dist/react-router.production.min.js.map +1 -1
- package/dist/umd/react-router.development.js +7 -9
- package/dist/umd/react-router.development.js.map +1 -1
- package/dist/umd/react-router.production.min.js +2 -2
- package/dist/umd/react-router.production.min.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# react-router
|
|
2
2
|
|
|
3
|
+
## 6.4.0-pre.7
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add support for functional updates in `useSearchParams` (similar to the `useState` callback signature) (#8955)
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Properly handle relative navigation from index/pathless routes (#8954)
|
|
12
|
+
- Fix issues building with webpack + React 17 (#8938)
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- `@remix-run/router@0.2.0-pre.2`
|
|
15
|
+
|
|
16
|
+
## 6.4.0-pre.6
|
|
17
|
+
|
|
18
|
+
## 6.4.0-pre.5
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Fix broken require for CJS builds
|
|
23
|
+
|
|
3
24
|
## 6.4.0-pre.4
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ActionFunction, DataRouteMatch, Fetcher, JsonFunction, LoaderFunction, Location, Navigation, Params, Path, PathMatch, PathPattern, RedirectFunction, RouteMatch, RouteObject, ShouldRevalidateFunction, To } from "@remix-run/router";
|
|
1
|
+
import type { ActionFunction, DataRouteMatch, Fetcher, JsonFunction, LoaderFunction, Location, Navigation, Params, ParamParseKey, Path, PathMatch, PathPattern, RedirectFunction, RouteMatch, RouteObject, ShouldRevalidateFunction, To } from "@remix-run/router";
|
|
2
2
|
import { Action as NavigationType, createPath, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from "@remix-run/router";
|
|
3
3
|
import type { DataMemoryRouterProps, MemoryRouterProps, NavigateProps, OutletProps, RouteProps, PathRouteProps, LayoutRouteProps, IndexRouteProps, RouterProps, RoutesProps } from "./lib/components";
|
|
4
4
|
import { createRoutesFromChildren, renderMatches, MemoryRouter, DataMemoryRouter, Navigate, Outlet, Route, Router, Routes, useRenderDataRouter } from "./lib/components";
|
|
@@ -9,7 +9,7 @@ import { useHref, useInRouterContext, useLocation, useMatch, useNavigationType,
|
|
|
9
9
|
declare type Hash = string;
|
|
10
10
|
declare type Pathname = string;
|
|
11
11
|
declare type Search = string;
|
|
12
|
-
export type { ActionFunction, DataMemoryRouterProps, DataRouteMatch, Fetcher, Hash, IndexRouteProps, JsonFunction, LayoutRouteProps, LoaderFunction, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, OutletProps, Params, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RouteMatch, RouteObject, RouteProps, RouterProps, RoutesProps, Search, ShouldRevalidateFunction, To, };
|
|
12
|
+
export type { ActionFunction, DataMemoryRouterProps, DataRouteMatch, Fetcher, Hash, IndexRouteProps, JsonFunction, LayoutRouteProps, LoaderFunction, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RouteMatch, RouteObject, RouteProps, RouterProps, RoutesProps, Search, ShouldRevalidateFunction, To, };
|
|
13
13
|
export { DataMemoryRouter, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, Routes, createPath, createRoutesFromChildren, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, useActionData, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, };
|
|
14
14
|
/** @internal */
|
|
15
15
|
export { NavigationContext as UNSAFE_NavigationContext, LocationContext as UNSAFE_LocationContext, RouteContext as UNSAFE_RouteContext, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, useRenderDataRouter, };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* React Router v6.4.0-pre.
|
|
2
|
+
* React Router v6.4.0-pre.7
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -191,6 +191,7 @@ const shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore
|
|
|
191
191
|
const useSyncExternalStore = "useSyncExternalStore" in React ? // @ts-expect-error
|
|
192
192
|
(module => module.useSyncExternalStore)(React) : shim;
|
|
193
193
|
|
|
194
|
+
// Contexts for data routers
|
|
194
195
|
const DataRouterContext = /*#__PURE__*/React.createContext(null);
|
|
195
196
|
|
|
196
197
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -317,13 +318,16 @@ function useMatch(pattern) {
|
|
|
317
318
|
} = useLocation();
|
|
318
319
|
return React.useMemo(() => matchPath(pattern, pathname), [pathname, pattern]);
|
|
319
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* The interface for the navigate() function returned from useNavigate().
|
|
323
|
+
*/
|
|
324
|
+
|
|
320
325
|
/**
|
|
321
326
|
* Returns an imperative method for changing the location. Used by <Link>s, but
|
|
322
327
|
* may also be used by other elements to change the location.
|
|
323
328
|
*
|
|
324
329
|
* @see https://reactrouter.com/docs/en/v6/hooks/use-navigate
|
|
325
330
|
*/
|
|
326
|
-
|
|
327
331
|
function useNavigate() {
|
|
328
332
|
!useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(false, // TODO: This error is probably because they somehow have 2 versions of the
|
|
329
333
|
// router loaded. We can help them understand how to avoid that.
|
|
@@ -337,8 +341,10 @@ function useNavigate() {
|
|
|
337
341
|
} = React.useContext(RouteContext);
|
|
338
342
|
let {
|
|
339
343
|
pathname: locationPathname
|
|
340
|
-
} = useLocation();
|
|
341
|
-
|
|
344
|
+
} = useLocation(); // Ignore index + pathless matches
|
|
345
|
+
|
|
346
|
+
let pathContributingMatches = matches.filter((match, index) => index === 0 || !match.route.index && match.pathnameBase !== matches[index - 1].pathnameBase);
|
|
347
|
+
let routePathnamesJson = JSON.stringify(pathContributingMatches.map(match => match.pathnameBase));
|
|
342
348
|
let activeRef = React.useRef(false);
|
|
343
349
|
React.useEffect(() => {
|
|
344
350
|
activeRef.current = true;
|
|
@@ -521,9 +527,9 @@ function DefaultErrorElement() {
|
|
|
521
527
|
}
|
|
522
528
|
}, message), error != null && error.stack ? /*#__PURE__*/React.createElement("pre", {
|
|
523
529
|
style: preStyles
|
|
524
|
-
}, error == null ? void 0 : error.stack) : null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\
|
|
530
|
+
}, error == null ? void 0 : error.stack) : null, /*#__PURE__*/React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), /*#__PURE__*/React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\xA0", /*#__PURE__*/React.createElement("code", {
|
|
525
531
|
style: codeStyles
|
|
526
|
-
}, "errorElement"), " props on\
|
|
532
|
+
}, "errorElement"), " props on\xA0", /*#__PURE__*/React.createElement("code", {
|
|
527
533
|
style: codeStyles
|
|
528
534
|
}, "<Route>")));
|
|
529
535
|
}
|
|
@@ -700,24 +706,20 @@ function useMatches() {
|
|
|
700
706
|
*/
|
|
701
707
|
|
|
702
708
|
function useLoaderData() {
|
|
703
|
-
var _state$loaderData;
|
|
704
|
-
|
|
705
709
|
let state = useDataRouterState(DataRouterHook.UseLoaderData);
|
|
706
710
|
let route = React.useContext(RouteContext);
|
|
707
711
|
!route ? process.env.NODE_ENV !== "production" ? invariant(false, "useLoaderData must be used inside a RouteContext") : invariant(false) : void 0;
|
|
708
712
|
let thisRoute = route.matches[route.matches.length - 1];
|
|
709
713
|
!thisRoute.route.id ? process.env.NODE_ENV !== "production" ? invariant(false, "useLoaderData can only be used on routes that contain a unique \"id\"") : invariant(false) : void 0;
|
|
710
|
-
return
|
|
714
|
+
return state.loaderData[thisRoute.route.id];
|
|
711
715
|
}
|
|
712
716
|
/**
|
|
713
717
|
* Returns the loaderData for the given routeId
|
|
714
718
|
*/
|
|
715
719
|
|
|
716
720
|
function useRouteLoaderData(routeId) {
|
|
717
|
-
var _state$loaderData2;
|
|
718
|
-
|
|
719
721
|
let state = useDataRouterState(DataRouterHook.UseRouteLoaderData);
|
|
720
|
-
return
|
|
722
|
+
return state.loaderData[routeId];
|
|
721
723
|
}
|
|
722
724
|
/**
|
|
723
725
|
* Returns the action data for the nearest ancestor Route action
|
|
@@ -840,12 +842,12 @@ function DataMemoryRouter(_ref2) {
|
|
|
840
842
|
})
|
|
841
843
|
});
|
|
842
844
|
}
|
|
845
|
+
|
|
843
846
|
/**
|
|
844
847
|
* A <Router> that stores all entries in memory.
|
|
845
848
|
*
|
|
846
849
|
* @see https://reactrouter.com/docs/en/v6/routers/memory-router
|
|
847
850
|
*/
|
|
848
|
-
|
|
849
851
|
function MemoryRouter(_ref3) {
|
|
850
852
|
let {
|
|
851
853
|
basename,
|
|
@@ -877,6 +879,7 @@ function MemoryRouter(_ref3) {
|
|
|
877
879
|
navigator: history
|
|
878
880
|
});
|
|
879
881
|
}
|
|
882
|
+
|
|
880
883
|
/**
|
|
881
884
|
* Changes the current location.
|
|
882
885
|
*
|
|
@@ -886,7 +889,6 @@ function MemoryRouter(_ref3) {
|
|
|
886
889
|
*
|
|
887
890
|
* @see https://reactrouter.com/docs/en/v6/components/navigate
|
|
888
891
|
*/
|
|
889
|
-
|
|
890
892
|
function Navigate(_ref4) {
|
|
891
893
|
let {
|
|
892
894
|
to,
|
|
@@ -906,24 +908,25 @@ function Navigate(_ref4) {
|
|
|
906
908
|
});
|
|
907
909
|
return null;
|
|
908
910
|
}
|
|
911
|
+
|
|
909
912
|
/**
|
|
910
913
|
* Renders the child route's element, if there is one.
|
|
911
914
|
*
|
|
912
915
|
* @see https://reactrouter.com/docs/en/v6/components/outlet
|
|
913
916
|
*/
|
|
914
|
-
|
|
915
917
|
function Outlet(props) {
|
|
916
918
|
return useOutlet(props.context);
|
|
917
919
|
}
|
|
920
|
+
|
|
918
921
|
/**
|
|
919
922
|
* Declares an element that should be rendered at a certain URL path.
|
|
920
923
|
*
|
|
921
924
|
* @see https://reactrouter.com/docs/en/v6/components/route
|
|
922
925
|
*/
|
|
923
|
-
|
|
924
926
|
function Route(_props) {
|
|
925
927
|
process.env.NODE_ENV !== "production" ? invariant(false, "A <Route> is only ever to be used as the child of <Routes> element, " + "never rendered directly. Please wrap your <Route> in a <Routes>.") : invariant(false) ;
|
|
926
928
|
}
|
|
929
|
+
|
|
927
930
|
/**
|
|
928
931
|
* Provides location context for the rest of the app.
|
|
929
932
|
*
|
|
@@ -933,7 +936,6 @@ function Route(_props) {
|
|
|
933
936
|
*
|
|
934
937
|
* @see https://reactrouter.com/docs/en/v6/routers/router
|
|
935
938
|
*/
|
|
936
|
-
|
|
937
939
|
function Router(_ref5) {
|
|
938
940
|
let {
|
|
939
941
|
basename: basenameProp = "/",
|
|
@@ -993,13 +995,13 @@ function Router(_ref5) {
|
|
|
993
995
|
}
|
|
994
996
|
}));
|
|
995
997
|
}
|
|
998
|
+
|
|
996
999
|
/**
|
|
997
1000
|
* A container for a nested tree of <Route> elements that renders the branch
|
|
998
1001
|
* that best matches the current location.
|
|
999
1002
|
*
|
|
1000
1003
|
* @see https://reactrouter.com/docs/en/v6/components/routes
|
|
1001
1004
|
*/
|
|
1002
|
-
|
|
1003
1005
|
function Routes(_ref6) {
|
|
1004
1006
|
let {
|
|
1005
1007
|
children,
|
|
@@ -1007,13 +1009,13 @@ function Routes(_ref6) {
|
|
|
1007
1009
|
} = _ref6;
|
|
1008
1010
|
return useRoutes(createRoutesFromChildren(children), location);
|
|
1009
1011
|
}
|
|
1012
|
+
|
|
1010
1013
|
/**
|
|
1011
1014
|
* @private
|
|
1012
1015
|
* Used as an extension to <Routes> and accepts a manual `routes` array to be
|
|
1013
1016
|
* instead of using JSX children. Extracted to it's own component to avoid
|
|
1014
1017
|
* conditional usage of `useRoutes` if we have to render a `fallbackElement`
|
|
1015
1018
|
*/
|
|
1016
|
-
|
|
1017
1019
|
function DataRoutes(_ref7) {
|
|
1018
1020
|
let {
|
|
1019
1021
|
children,
|