mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-14 04:08:32 +03:00
Memoize isModalPage
This commit is contained in:
parent
a0f16057a0
commit
71f177bebe
1 changed files with 6 additions and 3 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Reference in a new issue