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 { 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 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue