clear-react-router 1.2.3 → 1.2.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/dist/components/Router.d.ts +1 -1
- package/dist/index.js +7 -2
- package/package.json +1 -1
|
@@ -5,5 +5,5 @@ type RouterProps = {
|
|
|
5
5
|
isAnimated?: boolean;
|
|
6
6
|
animationOptions?: AnimationOptions;
|
|
7
7
|
};
|
|
8
|
-
export declare const Router: ({ routeList, context: initialContext, isAnimated, animationOptions, }: RouterProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const Router: ({ routeList, context: initialContext, isAnimated, animationOptions, }: RouterProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
9
9
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -409,10 +409,13 @@ var renderElement = (Component) => {
|
|
|
409
409
|
var PAGE_NOT_FOUND = "error 404. Page not found";
|
|
410
410
|
var ALL_LOCATIONS = "*";
|
|
411
411
|
var Router = ({ routeList, context: initialContext = {}, isAnimated = false, animationOptions = {} }) => {
|
|
412
|
-
const [location, setLocation] = useState(
|
|
412
|
+
const [location, setLocation] = useState({});
|
|
413
413
|
const [context, setContext] = useState(initialContext);
|
|
414
414
|
useApplyCustomAnimation(animationOptions);
|
|
415
|
-
const routeItem = useMemo(() =>
|
|
415
|
+
const routeItem = useMemo(() => {
|
|
416
|
+
if (!location.pathname) return void 0;
|
|
417
|
+
return routeList.find((el) => el.path === ALL_LOCATIONS || comparePaths(el, location.pathname));
|
|
418
|
+
}, [location.pathname, routeList]);
|
|
416
419
|
const params = useMemo(() => getParamsObject({
|
|
417
420
|
routeItem,
|
|
418
421
|
pathname: window.location.pathname
|
|
@@ -448,6 +451,8 @@ var Router = ({ routeList, context: initialContext = {}, isAnimated = false, ani
|
|
|
448
451
|
updateBlockedRoute,
|
|
449
452
|
updateLocation
|
|
450
453
|
]);
|
|
454
|
+
if (!routeItem && isLoading) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {});
|
|
455
|
+
if (!routeItem) return null;
|
|
451
456
|
if (!isAnimated && routeItem?.loader && !loaderError && isLoading) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouterProvider, {
|
|
452
457
|
...providerProps,
|
|
453
458
|
children: renderElement(routeItem?.loaderFallback)
|