Skip to content

Commit af9063d

Browse files
committed
fix: memoize ishome and use routes
1 parent 37d7b2a commit af9063d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

gui/src/components/Layout.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { OnboardingModes } from "core/protocol/core";
2-
import { useContext, useEffect, useState } from "react";
2+
import { useContext, useEffect, useMemo, useState } from "react";
33
import { Outlet, useLocation, useNavigate } from "react-router-dom";
44
import styled from "styled-components";
55
import { CustomScrollbarDiv } from ".";
@@ -54,8 +54,12 @@ const Layout = () => {
5454

5555
const showDialog = useAppSelector((state) => state.ui.showDialog);
5656
const isInEdit = useAppSelector((store) => store.session.isInEdit);
57-
const isHome =
58-
location.pathname === "/" || location.pathname === "/index.html";
57+
const isHome = useMemo(() => {
58+
return (
59+
location.pathname === ROUTES.HOME ||
60+
location.pathname === ROUTES.HOME_INDEX
61+
);
62+
}, []);
5963

6064
useEffect(() => {
6165
(async () => {

gui/src/util/navigation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type ConfigTab =
1212
// TODO: Move all the routes here
1313
export const ROUTES = {
1414
HOME: "/",
15+
HOME_INDEX: "/index.html",
1516
CONFIG: "/config",
1617
THEME: "/theme",
1718
STATS: "/stats",

0 commit comments

Comments
 (0)