From 71f177bebe7db15224482de939376e423a5d0405 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Sun, 10 Sep 2023 15:30:04 +0800 Subject: [PATCH] Memoize isModalPage --- src/app.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app.jsx b/src/app.jsx index 9ffeb119..16109f4c 100644 --- a/src/app.jsx +++ b/src/app.jsx @@ -201,9 +201,12 @@ function App() { const { prevLocation } = snapStates; const backgroundLocation = useRef(prevLocation || null); - const isModalPage = - matchPath('/:instance/s/:id', location.pathname) || - matchPath('/s/:id', location.pathname); + const isModalPage = useMemo(() => { + return ( + matchPath('/:instance/s/:id', location.pathname) || + matchPath('/s/:id', location.pathname) + ); + }, [location.pathname, matchPath]); if (isModalPage) { if (!backgroundLocation.current) backgroundLocation.current = prevLocation; } else {