From 8d037bb76fab5fac7626b7967e75e90db6e7c1c4 Mon Sep 17 00:00:00 2001 From: "nuo.o" <49533950+nuoxoxo@users.noreply.github.com> Date: Sun, 29 Oct 2023 11:00:44 +0100 Subject: [PATCH] Update App.tsx --- src/App.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index eedd0ef..ee76b38 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -58,11 +58,12 @@ function App() { */ const [route, setRoute] = useState(() => { + const len = Object.keys(routes).length const initialRoute = routeFromLocalStorage ? JSON.parse(routeFromLocalStorage) : Object.keys(routes)[ - Math.floor(Math.random() * Object.keys(routes).length) + Math.floor(Math.random() * len /*Object.keys(routes).length*/) ] // handleSetRoute(initialRoute) // hoisting seems wrong in strictMode localStorage.setItem("route", JSON.stringify(initialRoute));