mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-15 02:18:51 +01:00
Don't need useEffect for backgroundLocation
This commit is contained in:
parent
d66d1bca12
commit
37fc65b47a
1 changed files with 12 additions and 14 deletions
16
src/app.jsx
16
src/app.jsx
|
@ -182,20 +182,18 @@ function App() {
|
||||||
}
|
}
|
||||||
}, [isLoggedIn]);
|
}, [isLoggedIn]);
|
||||||
|
|
||||||
const backgroundLocation = useRef();
|
|
||||||
useEffect(() => {
|
|
||||||
const { prevLocation } = snapStates;
|
const { prevLocation } = snapStates;
|
||||||
const { pathname } = location;
|
const backgroundLocation = useRef(prevLocation || null);
|
||||||
const { pathname: prevPathname } = prevLocation || {};
|
const isModalPage = /^\/s\//i.test(location.pathname);
|
||||||
console.debug({ prevPathname, pathname });
|
|
||||||
const isModalPage = /^\/s\//i.test(pathname);
|
|
||||||
if (isModalPage) {
|
if (isModalPage) {
|
||||||
if (!backgroundLocation.current)
|
if (!backgroundLocation.current) backgroundLocation.current = prevLocation;
|
||||||
backgroundLocation.current = prevLocation;
|
|
||||||
} else {
|
} else {
|
||||||
backgroundLocation.current = null;
|
backgroundLocation.current = null;
|
||||||
}
|
}
|
||||||
}, [location]);
|
console.debug({
|
||||||
|
backgroundLocation: backgroundLocation.current,
|
||||||
|
location,
|
||||||
|
});
|
||||||
|
|
||||||
const nonRootLocation = useMemo(() => {
|
const nonRootLocation = useMemo(() => {
|
||||||
const { pathname } = location;
|
const { pathname } = location;
|
||||||
|
|
Loading…
Reference in a new issue