aboutsummaryrefslogtreecommitdiff
path: root/packages/hooks
diff options
context:
space:
mode:
authorDhravya Shah <[email protected]>2025-09-18 20:34:18 -0700
committerDhravya Shah <[email protected]>2025-09-18 21:03:49 -0700
commit1fcb56908920da386900abb4ce2383374a625c72 (patch)
tree0f9d7f695d4c9b1b85be3950fc869e0061dff3ed /packages/hooks
parentrefetching logic change (diff)
downloadsupermemory-09-18-formatting.tar.xz
supermemory-09-18-formatting.zip
Diffstat (limited to 'packages/hooks')
-rw-r--r--packages/hooks/use-keypress.ts16
-rw-r--r--packages/hooks/use-mobile.ts24
2 files changed, 21 insertions, 19 deletions
diff --git a/packages/hooks/use-keypress.ts b/packages/hooks/use-keypress.ts
index 42906660..eee23acb 100644
--- a/packages/hooks/use-keypress.ts
+++ b/packages/hooks/use-keypress.ts
@@ -1,15 +1,15 @@
-import { useEffect } from "react"
+import { useEffect } from "react";
export const useKeyPress = (key: string, callback: () => void) => {
useEffect(() => {
const handler = (e: KeyboardEvent) => {
if (e.key === key && e.altKey) {
- callback()
+ callback();
}
- }
- window.addEventListener("keydown", handler)
+ };
+ window.addEventListener("keydown", handler);
return () => {
- window.removeEventListener("keydown", handler)
- }
- }, [key, callback])
-}
+ window.removeEventListener("keydown", handler);
+ };
+ }, [key, callback]);
+};
diff --git a/packages/hooks/use-mobile.ts b/packages/hooks/use-mobile.ts
index 283bbb4c..0a892310 100644
--- a/packages/hooks/use-mobile.ts
+++ b/packages/hooks/use-mobile.ts
@@ -1,19 +1,21 @@
-import * as React from "react"
+import * as React from "react";
-const MOBILE_BREAKPOINT = 768
+const MOBILE_BREAKPOINT = 768;
export function useIsMobile() {
- const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
+ undefined,
+ );
React.useEffect(() => {
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
const onChange = () => {
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
- }
- mql.addEventListener("change", onChange)
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
- return () => mql.removeEventListener("change", onChange)
- }, [])
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
+ };
+ mql.addEventListener("change", onChange);
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
+ return () => mql.removeEventListener("change", onChange);
+ }, []);
- return !!isMobile
+ return !!isMobile;
}