@tanstack/react-router 0.0.1-beta.25 → 0.0.1-beta.27
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/build/cjs/react-router/src/index.js +41 -7
- package/build/cjs/react-router/src/index.js.map +1 -1
- package/build/cjs/router-core/build/esm/index.js +6 -4
- package/build/cjs/router-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +47 -11
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +29 -29
- package/build/types/index.d.ts +1 -1
- package/build/umd/index.development.js +47 -11
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +52 -5
package/build/esm/index.js
CHANGED
|
@@ -1054,7 +1054,7 @@ function parsePathname(pathname) {
|
|
|
1054
1054
|
};
|
|
1055
1055
|
}
|
|
1056
1056
|
|
|
1057
|
-
if (part.charAt(0) === '
|
|
1057
|
+
if (part.charAt(0) === '$') {
|
|
1058
1058
|
return {
|
|
1059
1059
|
type: 'param',
|
|
1060
1060
|
value: part
|
|
@@ -1151,7 +1151,7 @@ function matchByPath(from, matchLocation) {
|
|
|
1151
1151
|
return false;
|
|
1152
1152
|
}
|
|
1153
1153
|
|
|
1154
|
-
if (
|
|
1154
|
+
if (baseSegment.value.charAt(0) !== '$') {
|
|
1155
1155
|
params[routeSegment.value.substring(1)] = baseSegment.value;
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
@@ -1413,9 +1413,11 @@ const createRouteConfig = function createRouteConfig(options, children, isRoot,
|
|
|
1413
1413
|
fullPath: fullPath,
|
|
1414
1414
|
options: options,
|
|
1415
1415
|
children,
|
|
1416
|
-
createChildren: cb => createRouteConfig(options, cb(childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath)), false, parentId, parentPath),
|
|
1417
1416
|
addChildren: children => createRouteConfig(options, children, false, parentId, parentPath),
|
|
1418
|
-
createRoute: childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath)
|
|
1417
|
+
createRoute: childOptions => createRouteConfig(childOptions, undefined, false, id, fullPath),
|
|
1418
|
+
generate: () => {
|
|
1419
|
+
invariant(false, "routeConfig.generate() is used by TanStack Router's file-based routing code generation and should not actually be called during runtime. ");
|
|
1420
|
+
}
|
|
1419
1421
|
};
|
|
1420
1422
|
};
|
|
1421
1423
|
|
|
@@ -2812,7 +2814,8 @@ function Outlet() {
|
|
|
2812
2814
|
}, /*#__PURE__*/React.createElement(React.Suspense, {
|
|
2813
2815
|
fallback: /*#__PURE__*/React.createElement(PendingComponent, null)
|
|
2814
2816
|
}, /*#__PURE__*/React.createElement(CatchBoundary, {
|
|
2815
|
-
errorComponent: errorComponent
|
|
2817
|
+
errorComponent: errorComponent,
|
|
2818
|
+
key: match.routeId
|
|
2816
2819
|
}, (() => {
|
|
2817
2820
|
if (match.status === 'error') {
|
|
2818
2821
|
throw match.error;
|
|
@@ -2832,7 +2835,8 @@ class CatchBoundary extends React.Component {
|
|
|
2832
2835
|
constructor() {
|
|
2833
2836
|
super(...arguments);
|
|
2834
2837
|
this.state = {
|
|
2835
|
-
error: false
|
|
2838
|
+
error: false,
|
|
2839
|
+
info: undefined
|
|
2836
2840
|
};
|
|
2837
2841
|
}
|
|
2838
2842
|
|
|
@@ -2845,17 +2849,49 @@ class CatchBoundary extends React.Component {
|
|
|
2845
2849
|
}
|
|
2846
2850
|
|
|
2847
2851
|
render() {
|
|
2848
|
-
|
|
2852
|
+
return /*#__PURE__*/React.createElement(CatchBoundaryInner, _extends$2({}, this.props, {
|
|
2853
|
+
errorState: this.state,
|
|
2854
|
+
reset: () => this.setState({})
|
|
2855
|
+
}));
|
|
2856
|
+
}
|
|
2857
|
+
|
|
2858
|
+
} // This is the messiest thing ever... I'm either seriously tired (likely) or
|
|
2859
|
+
// there has to be a better way to reset error boundaries when the
|
|
2860
|
+
// router's location key changes.
|
|
2849
2861
|
|
|
2850
|
-
const errorComponent = (_this$props$errorComp = this.props.errorComponent) != null ? _this$props$errorComp : DefaultErrorBoundary;
|
|
2851
2862
|
|
|
2852
|
-
|
|
2853
|
-
|
|
2863
|
+
function CatchBoundaryInner(props) {
|
|
2864
|
+
var _props$errorComponent;
|
|
2865
|
+
|
|
2866
|
+
const [activeErrorState, setActiveErrorState] = React.useState(props.errorState);
|
|
2867
|
+
const router = useRouter();
|
|
2868
|
+
const errorComponent = (_props$errorComponent = props.errorComponent) != null ? _props$errorComponent : DefaultErrorBoundary;
|
|
2869
|
+
React.useEffect(() => {
|
|
2870
|
+
if (activeErrorState) {
|
|
2871
|
+
let prevKey = router.state.location.key;
|
|
2872
|
+
return router.subscribe(() => {
|
|
2873
|
+
if (router.state.location.key !== prevKey) {
|
|
2874
|
+
prevKey = router.state.location.key;
|
|
2875
|
+
setActiveErrorState({});
|
|
2876
|
+
}
|
|
2877
|
+
});
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
return;
|
|
2881
|
+
}, [activeErrorState]);
|
|
2882
|
+
React.useEffect(() => {
|
|
2883
|
+
if (props.errorState.error) {
|
|
2884
|
+
setActiveErrorState(props.errorState);
|
|
2854
2885
|
}
|
|
2855
2886
|
|
|
2856
|
-
|
|
2887
|
+
props.reset();
|
|
2888
|
+
}, [props.errorState.error]);
|
|
2889
|
+
|
|
2890
|
+
if (activeErrorState.error) {
|
|
2891
|
+
return /*#__PURE__*/React.createElement(errorComponent, activeErrorState);
|
|
2857
2892
|
}
|
|
2858
2893
|
|
|
2894
|
+
return props.children;
|
|
2859
2895
|
}
|
|
2860
2896
|
|
|
2861
2897
|
function DefaultErrorBoundary(_ref6) {
|