Memoize isModalPage

This commit is contained in:
Lim Chee Aun 2023-09-10 15:30:04 +08:00
parent a0f16057a0
commit 71f177bebe

View file

@ -201,9 +201,12 @@ function App() {
const { prevLocation } = snapStates; const { prevLocation } = snapStates;
const backgroundLocation = useRef(prevLocation || null); const backgroundLocation = useRef(prevLocation || null);
const isModalPage = const isModalPage = useMemo(() => {
return (
matchPath('/:instance/s/:id', location.pathname) || matchPath('/:instance/s/:id', location.pathname) ||
matchPath('/s/:id', location.pathname); matchPath('/s/:id', location.pathname)
);
}, [location.pathname, matchPath]);
if (isModalPage) { if (isModalPage) {
if (!backgroundLocation.current) backgroundLocation.current = prevLocation; if (!backgroundLocation.current) backgroundLocation.current = prevLocation;
} else { } else {