fix: infinite call of useEffect on 404 page (#913)
This commit is contained in:
@@ -40,7 +40,6 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
|||||||
// Add ‘⌘+K’ shortcut keys as switches
|
// Add ‘⌘+K’ shortcut keys as switches
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (router.pathname.startsWith('/404')) {
|
if (router.pathname.startsWith('/404')) {
|
||||||
triggerQuickSearchModal(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const down = (e: KeyboardEvent) => {
|
const down = (e: KeyboardEvent) => {
|
||||||
@@ -59,7 +58,7 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
|||||||
document.addEventListener('keydown', down, { capture: true });
|
document.addEventListener('keydown', down, { capture: true });
|
||||||
return () =>
|
return () =>
|
||||||
document.removeEventListener('keydown', down, { capture: true });
|
document.removeEventListener('keydown', down, { capture: true });
|
||||||
}, [open, router.pathname, triggerQuickSearchModal]);
|
}, [open, router, triggerQuickSearchModal]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (router.pathname.startsWith('/public-workspace')) {
|
if (router.pathname.startsWith('/public-workspace')) {
|
||||||
@@ -68,6 +67,12 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
|
|||||||
return setIsPublic(false);
|
return setIsPublic(false);
|
||||||
}
|
}
|
||||||
}, [router]);
|
}, [router]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (router.pathname.startsWith('/404')) {
|
||||||
|
return onClose();
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
|||||||
Reference in New Issue
Block a user