clear-react-router 1.2.3 → 1.2.4

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.
@@ -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(parseWindowLocation(window.location));
412
+ const [location, setLocation] = useState({});
413
413
  const [context, setContext] = useState(initialContext);
414
414
  useApplyCustomAnimation(animationOptions);
415
- const routeItem = useMemo(() => routeList.find((el) => el.path === ALL_LOCATIONS || comparePaths(el, location.pathname)), [location.pathname, routeList]);
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,7 @@ var Router = ({ routeList, context: initialContext = {}, isAnimated = false, ani
448
451
  updateBlockedRoute,
449
452
  updateLocation
450
453
  ]);
454
+ if (!routeItem) return null;
451
455
  if (!isAnimated && routeItem?.loader && !loaderError && isLoading) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RouterProvider, {
452
456
  ...providerProps,
453
457
  children: renderElement(routeItem?.loaderFallback)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clear-react-router",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "A lightweight, type-safe routing library for React applications",
5
5
  "author": "Andrew Bubnov",
6
6
  "scripts": {