Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: infinite call of useEffect on 404 page (#913)

JimmFly0ccaf2bc45ee
diff --git a/packages/app/src/components/quick-search/index.tsx b/packages/app/src/components/quick-search/index.tsx
index 97921efca7..fd14899abb 100644
--- a/packages/app/src/components/quick-search/index.tsx
+++ b/packages/app/src/components/quick-search/index.tsx
@@ -40,7 +40,6 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
// Add ‘⌘+K’ shortcut keys as switches
useEffect(() => {
if (router.pathname.startsWith('/404')) {
- triggerQuickSearchModal(false);
return;
}
const down = (e: KeyboardEvent) => {
@@ -59,7 +58,7 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
document.addEventListener('keydown', down, { capture: true });
return () =>
document.removeEventListener('keydown', down, { capture: true });
- }, [open, router.pathname, triggerQuickSearchModal]);
+ }, [open, router, triggerQuickSearchModal]);
useEffect(() => {
if (router.pathname.startsWith('/public-workspace')) {
@@ -68,6 +67,12 @@ export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => {
return setIsPublic(false);
}
}, [router]);
+ useEffect(() => {
+ if (router.pathname.startsWith('/404')) {
+ return onClose();
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
return (
<Modal