@tanstack/react-router 0.0.1-beta.252 → 0.0.1-beta.254
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/router.js +13 -7
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +13 -7
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +357 -357
- package/build/umd/index.development.js +13 -8
- 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/routeInfo.ts +6 -6
- package/src/router.ts +15 -7
|
@@ -207,7 +207,6 @@
|
|
|
207
207
|
|
|
208
208
|
// This function queues up a call to update the browser history
|
|
209
209
|
const queueHistoryAction = (type, destHref, state, onUpdate) => {
|
|
210
|
-
console.log(destHref);
|
|
211
210
|
const href = createHref(destHref);
|
|
212
211
|
if (!scheduled) {
|
|
213
212
|
rollbackLocation = currentLocation;
|
|
@@ -2421,7 +2420,7 @@
|
|
|
2421
2420
|
for (let [index, match] of matches.entries()) {
|
|
2422
2421
|
const parentMatch = matches[index - 1];
|
|
2423
2422
|
const route = this.looseRoutesById[match.routeId];
|
|
2424
|
-
const
|
|
2423
|
+
const handleErrorAndRedirect = (err, code) => {
|
|
2425
2424
|
err.routerCode = code;
|
|
2426
2425
|
firstBadMatchIndex = firstBadMatchIndex ?? index;
|
|
2427
2426
|
if (isRedirect(err)) {
|
|
@@ -2444,10 +2443,10 @@
|
|
|
2444
2443
|
};
|
|
2445
2444
|
try {
|
|
2446
2445
|
if (match.paramsError) {
|
|
2447
|
-
|
|
2446
|
+
handleErrorAndRedirect(match.paramsError, 'PARSE_PARAMS');
|
|
2448
2447
|
}
|
|
2449
2448
|
if (match.searchError) {
|
|
2450
|
-
|
|
2449
|
+
handleErrorAndRedirect(match.searchError, 'VALIDATE_SEARCH');
|
|
2451
2450
|
}
|
|
2452
2451
|
const parentContext = parentMatch?.context ?? this.options.context ?? {};
|
|
2453
2452
|
const beforeLoadContext = (await route.options.beforeLoad?.({
|
|
@@ -2465,6 +2464,9 @@
|
|
|
2465
2464
|
buildLocation: this.buildLocation,
|
|
2466
2465
|
cause: match.cause
|
|
2467
2466
|
})) ?? {};
|
|
2467
|
+
if (isRedirect(beforeLoadContext)) {
|
|
2468
|
+
throw beforeLoadContext;
|
|
2469
|
+
}
|
|
2468
2470
|
const context = {
|
|
2469
2471
|
...parentContext,
|
|
2470
2472
|
...beforeLoadContext
|
|
@@ -2474,7 +2476,7 @@
|
|
|
2474
2476
|
context: replaceEqualDeep(match.context, context)
|
|
2475
2477
|
};
|
|
2476
2478
|
} catch (err) {
|
|
2477
|
-
|
|
2479
|
+
handleErrorAndRedirect(err, 'BEFORE_LOAD');
|
|
2478
2480
|
break;
|
|
2479
2481
|
}
|
|
2480
2482
|
}
|
|
@@ -2491,7 +2493,7 @@
|
|
|
2491
2493
|
matchPromises.push((async () => {
|
|
2492
2494
|
const parentMatchPromise = matchPromises[index - 1];
|
|
2493
2495
|
const route = this.looseRoutesById[match.routeId];
|
|
2494
|
-
const
|
|
2496
|
+
const handleErrorAndRedirect = err => {
|
|
2495
2497
|
if (isRedirect(err)) {
|
|
2496
2498
|
if (!preload) {
|
|
2497
2499
|
this.navigate(err);
|
|
@@ -2593,6 +2595,9 @@
|
|
|
2593
2595
|
try {
|
|
2594
2596
|
const loaderData = await loadPromise;
|
|
2595
2597
|
if (latestPromise = checkLatest()) return await latestPromise;
|
|
2598
|
+
if (isRedirect(loaderData)) {
|
|
2599
|
+
if (handleErrorAndRedirect(loaderData)) return;
|
|
2600
|
+
}
|
|
2596
2601
|
if (didShowPending && pendingMinMs) {
|
|
2597
2602
|
await new Promise(r => setTimeout(r, pendingMinMs));
|
|
2598
2603
|
}
|
|
@@ -2608,12 +2613,12 @@
|
|
|
2608
2613
|
};
|
|
2609
2614
|
} catch (error) {
|
|
2610
2615
|
if (latestPromise = checkLatest()) return await latestPromise;
|
|
2611
|
-
if (
|
|
2616
|
+
if (handleErrorAndRedirect(error)) return;
|
|
2612
2617
|
try {
|
|
2613
2618
|
route.options.onError?.(error);
|
|
2614
2619
|
} catch (onErrorError) {
|
|
2615
2620
|
error = onErrorError;
|
|
2616
|
-
if (
|
|
2621
|
+
if (handleErrorAndRedirect(onErrorError)) return;
|
|
2617
2622
|
}
|
|
2618
2623
|
matches[index] = match = {
|
|
2619
2624
|
...match,
|