1
0
Fork 0

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 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 {