react-router 6.11.0 → 6.11.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 +10 -0
- package/dist/index.js +34 -21
- package/dist/index.js.map +1 -1
- package/dist/lib/context.d.ts +1 -0
- package/dist/main.js +1 -1
- package/dist/react-router.development.js +35 -22
- 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 +34 -21
- 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,15 @@
|
|
|
1
1
|
# `react-router`
|
|
2
2
|
|
|
3
|
+
## 6.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix usage of `Component` API within descendant `<Routes>` ([#10434](https://github.com/remix-run/react-router/pull/10434))
|
|
8
|
+
- Fix bug when calling `useNavigate` from `<Routes>` inside a `<RouterProvider>` ([#10432](https://github.com/remix-run/react-router/pull/10432))
|
|
9
|
+
- Fix usage of `<Navigate>` in strict mode when using a data router ([#10435](https://github.com/remix-run/react-router/pull/10435))
|
|
10
|
+
- Updated dependencies:
|
|
11
|
+
- `@remix-run/router@1.6.1`
|
|
12
|
+
|
|
3
13
|
## 6.11.0
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* React Router v6.11.
|
|
2
|
+
* React Router v6.11.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -61,7 +61,8 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
61
61
|
|
|
62
62
|
const RouteContext = /*#__PURE__*/React.createContext({
|
|
63
63
|
outlet: null,
|
|
64
|
-
matches: []
|
|
64
|
+
matches: [],
|
|
65
|
+
isDataRoute: false
|
|
65
66
|
});
|
|
66
67
|
|
|
67
68
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -192,10 +193,12 @@ function useIsomorphicLayoutEffect(cb) {
|
|
|
192
193
|
|
|
193
194
|
|
|
194
195
|
function useNavigate() {
|
|
195
|
-
let
|
|
196
|
+
let {
|
|
197
|
+
isDataRoute
|
|
198
|
+
} = React.useContext(RouteContext); // Conditional usage is OK here because the usage of a data router is static
|
|
196
199
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
197
200
|
|
|
198
|
-
return
|
|
201
|
+
return isDataRoute ? useNavigateStable() : useNavigateUnstable();
|
|
199
202
|
}
|
|
200
203
|
|
|
201
204
|
function useNavigateUnstable() {
|
|
@@ -574,6 +577,14 @@ function _renderMatches(matches, parentMatches, dataRouterState) {
|
|
|
574
577
|
|
|
575
578
|
if (error) {
|
|
576
579
|
children = errorElement;
|
|
580
|
+
} else if (match.route.Component) {
|
|
581
|
+
// Note: This is a de-optimized path since React won't re-use the
|
|
582
|
+
// ReactElement since it's identity changes with each new
|
|
583
|
+
// React.createElement call. We keep this so folks can use
|
|
584
|
+
// `<Route Component={...}>` in `<Routes>` but generally `Component`
|
|
585
|
+
// usage is only advised in `RouterProvider` when we can convert it to
|
|
586
|
+
// `element` ahead of time.
|
|
587
|
+
children = /*#__PURE__*/React.createElement(match.route.Component, null);
|
|
577
588
|
} else if (match.route.element) {
|
|
578
589
|
children = match.route.element;
|
|
579
590
|
} else {
|
|
@@ -584,7 +595,8 @@ function _renderMatches(matches, parentMatches, dataRouterState) {
|
|
|
584
595
|
match: match,
|
|
585
596
|
routeContext: {
|
|
586
597
|
outlet,
|
|
587
|
-
matches
|
|
598
|
+
matches,
|
|
599
|
+
isDataRoute: dataRouterState != null
|
|
588
600
|
},
|
|
589
601
|
children: children
|
|
590
602
|
});
|
|
@@ -601,7 +613,8 @@ function _renderMatches(matches, parentMatches, dataRouterState) {
|
|
|
601
613
|
children: getChildren(),
|
|
602
614
|
routeContext: {
|
|
603
615
|
outlet: null,
|
|
604
|
-
matches
|
|
616
|
+
matches,
|
|
617
|
+
isDataRoute: true
|
|
605
618
|
}
|
|
606
619
|
}) : getChildren();
|
|
607
620
|
}, null);
|
|
@@ -974,22 +987,22 @@ function Navigate(_ref4) {
|
|
|
974
987
|
// the router loaded. We can help them understand how to avoid that.
|
|
975
988
|
"<Navigate> may be used only in the context of a <Router> component.") : UNSAFE_invariant(false) : void 0;
|
|
976
989
|
process.env.NODE_ENV !== "production" ? UNSAFE_warning(!React.useContext(NavigationContext).static, "<Navigate> must not be used on the initial render in a <StaticRouter>. " + "This is a no-op, but you should modify your code so the <Navigate> is " + "only ever rendered in response to some user interaction or state change.") : void 0;
|
|
977
|
-
let
|
|
978
|
-
|
|
979
|
-
React.
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
}
|
|
990
|
+
let {
|
|
991
|
+
matches
|
|
992
|
+
} = React.useContext(RouteContext);
|
|
993
|
+
let {
|
|
994
|
+
pathname: locationPathname
|
|
995
|
+
} = useLocation();
|
|
996
|
+
let navigate = useNavigate(); // Resolve the path outside of the effect so that when effects run twice in
|
|
997
|
+
// StrictMode they navigate to the same place
|
|
986
998
|
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
999
|
+
let path = resolveTo(to, UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase), locationPathname, relative === "path");
|
|
1000
|
+
let jsonPath = JSON.stringify(path);
|
|
1001
|
+
React.useEffect(() => navigate(JSON.parse(jsonPath), {
|
|
1002
|
+
replace,
|
|
1003
|
+
state,
|
|
1004
|
+
relative
|
|
1005
|
+
}), [navigate, jsonPath, relative, replace, state]);
|
|
993
1006
|
return null;
|
|
994
1007
|
}
|
|
995
1008
|
|