From 48ef8c495eb0d0ad8fcbeb0010c301782c12c053 Mon Sep 17 00:00:00 2001 From: Sergey Elpashev Date: Thu, 3 Apr 2025 15:19:49 +0300 Subject: [PATCH] feat: some location optimization --- src/app.tsx | 4 ++-- src/components/menu.tsx | 6 +++--- src/pages/login.tsx | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app.tsx b/src/app.tsx index cdcac73..03fabaf 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -5,8 +5,8 @@ import LoginPage from "./pages/login"; import { AppProvider } from "./providers/AuthProvider"; const HomePage: FunctionComponent = () => { - const location = useLocation(); - location.route("/login"); + const { route } = useLocation(); + route("/login"); return
Redirecting to login...
; }; diff --git a/src/components/menu.tsx b/src/components/menu.tsx index 87406bd..6ca4232 100644 --- a/src/components/menu.tsx +++ b/src/components/menu.tsx @@ -9,8 +9,8 @@ interface MenuItemProps { } const MenuItem: FunctionComponent = ({ title, link }: MenuItemProps) => { - const location = useLocation(); - const active = location.path === link; + const { route, path } = useLocation(); + const active = path === link; const menuItemClasses = tv({ base: classes.menu_item, variants: { @@ -24,7 +24,7 @@ const MenuItem: FunctionComponent = ({ title, link }: MenuItemPro }, }); return ( -
location.route(link)}> +
route(link, true)}> {title}
); diff --git a/src/pages/login.tsx b/src/pages/login.tsx index 5ec097c..a181a3e 100644 --- a/src/pages/login.tsx +++ b/src/pages/login.tsx @@ -6,7 +6,7 @@ import { useLocation } from "preact-iso"; import classes from "./login.module.scss"; const LoginPage: FunctionComponent = () => { const { isLoggedIn } = useAppContext(); - const location = useLocation(); + const { route } = useLocation(); return (
@@ -16,7 +16,7 @@ const LoginPage: FunctionComponent = () => {