clear-react-router 2.5.3 → 2.5.5
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/README.md +4 -0
- package/dist/index.js +19 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,10 @@ It provides first-class support for:
|
|
|
21
21
|
|
|
22
22
|
> TL;DR? **[Try the live playground](https://clear-react-router.vercel.app/playground)** — no setup, click around.
|
|
23
23
|
|
|
24
|
+
> Need compile-time route safety and are okay with a build step, file-based route conventions, and a generated route tree in exchange? Check out
|
|
25
|
+
> [Clear Safe Router](https://github.com/AndrewBubnov/clear-safe-router) ([npm](https://www.npmjs.com/package/clear-safe-router)) —
|
|
26
|
+
> built on this runtime.
|
|
27
|
+
|
|
24
28
|
|
|
25
29
|
## Features
|
|
26
30
|
|
package/dist/index.js
CHANGED
|
@@ -373,8 +373,16 @@ var createNavigate = (routerState, revalidateCache, syncCacheSnapshot) => {
|
|
|
373
373
|
params,
|
|
374
374
|
searchParams
|
|
375
375
|
};
|
|
376
|
-
if (routeItem?.afterLoad)
|
|
377
|
-
|
|
376
|
+
if (routeItem?.afterLoad) try {
|
|
377
|
+
await routeItem.afterLoad(args);
|
|
378
|
+
} catch (error) {
|
|
379
|
+
console.error("[clear-router] Route afterLoad failed:", error);
|
|
380
|
+
}
|
|
381
|
+
if (defaultAfterLoad) try {
|
|
382
|
+
await defaultAfterLoad(args);
|
|
383
|
+
} catch (error) {
|
|
384
|
+
console.error("[clear-router] Default afterLoad failed:", error);
|
|
385
|
+
}
|
|
378
386
|
};
|
|
379
387
|
const checkBlocked = (nextLocation) => {
|
|
380
388
|
const currentState = blockerState.getState();
|
|
@@ -584,8 +592,9 @@ var createRevalidateCache = (routerState, syncCacheSnapshot) => {
|
|
|
584
592
|
const path = `${pathname}${search}`;
|
|
585
593
|
if (loadingPromises.has(path)) {
|
|
586
594
|
const owner = flightOwners.get(path);
|
|
587
|
-
|
|
588
|
-
|
|
595
|
+
const ownerWasAborted = owner instanceof AbortController ? owner.signal.aborted : owner?.aborted;
|
|
596
|
+
if (signal && owner instanceof AbortController || ownerWasAborted) {
|
|
597
|
+
if (owner instanceof AbortController) owner.abort();
|
|
589
598
|
loadingPromises.delete(path);
|
|
590
599
|
flightOwners.delete(path);
|
|
591
600
|
syncCacheSnapshot();
|
|
@@ -623,6 +632,10 @@ var createRevalidateCache = (routerState, syncCacheSnapshot) => {
|
|
|
623
632
|
signal: effectiveSignal,
|
|
624
633
|
attempt: retried + 1
|
|
625
634
|
});
|
|
635
|
+
if (!isOwner() || effectiveSignal.aborted) return {
|
|
636
|
+
data: null,
|
|
637
|
+
error: null
|
|
638
|
+
};
|
|
626
639
|
const resolvedStaleTime = routeItem.staleTime ?? routerConfig.defaultStaleTime ?? 0;
|
|
627
640
|
loaderMap.set(path, {
|
|
628
641
|
state: {
|
|
@@ -641,7 +654,7 @@ var createRevalidateCache = (routerState, syncCacheSnapshot) => {
|
|
|
641
654
|
error: null
|
|
642
655
|
};
|
|
643
656
|
} catch (error) {
|
|
644
|
-
if (effectiveSignal.aborted) return {
|
|
657
|
+
if (effectiveSignal.aborted || !isOwner()) return {
|
|
645
658
|
data: null,
|
|
646
659
|
error: null
|
|
647
660
|
};
|
|
@@ -993,7 +1006,6 @@ var Router = ({ routes, defaultBeforeLoad, defaultAfterLoad, animationDuration,
|
|
|
993
1006
|
const status = useRouteDataSelector((state) => state.status);
|
|
994
1007
|
const isError = status === "error";
|
|
995
1008
|
const isLoading = status === "pending";
|
|
996
|
-
useNavigation();
|
|
997
1009
|
useSetRouterConfig({
|
|
998
1010
|
routes,
|
|
999
1011
|
isAnimated,
|
|
@@ -1014,6 +1026,7 @@ var Router = ({ routes, defaultBeforeLoad, defaultAfterLoad, animationDuration,
|
|
|
1014
1026
|
useSetInitialContext(initialContext);
|
|
1015
1027
|
useRestoreRouteScroll(defaultScrollRestorationBehavior);
|
|
1016
1028
|
useReload();
|
|
1029
|
+
useNavigation();
|
|
1017
1030
|
const loadingContent = isLoading && !isError;
|
|
1018
1031
|
if (!routeItem) return renderElement(loadingContent ? defaultLoaderFallback : void 0);
|
|
1019
1032
|
const content = loadingContent ? renderElement(routeItem.loaderFallback || defaultLoaderFallback) : isError ? renderElement(routeItem.errorElement || defaultErrorElement) : /* @__PURE__ */ jsx(ErrorBoundary, { children: renderElement(routeItem.element) }, location.pathname);
|