From 8bf3f3105645ff66e1eb4ff2a0aa1ad260cac02c Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 23 Oct 2023 16:23:33 +0800 Subject: [PATCH] Slight rewrite, possibly breaking --- src/app.jsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app.jsx b/src/app.jsx index 5b03521a..a673a34e 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -267,11 +267,14 @@ function PrimaryRoutes({ isLoggedIn, loading }) { ); } +function getPrevLocation() { + return states.prevLocation || null; +} function SecondaryRoutes({ isLoggedIn }) { - const snapStates = useSnapshot(states); + // const snapStates = useSnapshot(states); const location = useLocation(); - const prevLocation = snapStates.prevLocation; - const backgroundLocation = useRef(prevLocation || null); + // const prevLocation = snapStates.prevLocation; + const backgroundLocation = useRef(getPrevLocation()); const isModalPage = useMemo(() => { return ( @@ -280,7 +283,8 @@ function SecondaryRoutes({ isLoggedIn }) { ); }, [location.pathname, matchPath]); if (isModalPage) { - if (!backgroundLocation.current) backgroundLocation.current = prevLocation; + if (!backgroundLocation.current) + backgroundLocation.current = getPrevLocation(); } else { backgroundLocation.current = null; }