The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 06:45 UTC
perf(web): useMediaQuery compiles without manual memoization (#20629)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 21:59 UTC
e544a4a1f6dc599eea71e9b2fb7f28d0ed9cbe02
1 file changed
+10
-13
apps/web/src/hooks/useMediaQuery.ts
+10
-13
@@ -1,4 +1,4 @@
1
-import { useCallback, useSyncExternalStore } from "react";
1
+import { useSyncExternalStore } from "react";
2
3
const BREAKPOINTS = {
4
"2xl": 1536,
@@ -63,20 +63,17 @@ export type MediaQueryInput = {
63
export function useMediaQuery(query: BreakpointQuery | MediaQueryInput | (string & {})): boolean {
64
const mediaQuery = parseQuery(query);
65
66
- const subscribe = useCallback(
67
- (callback: () => void) => {
68
- if (typeof window === "undefined") return () => {};
69
- const mql = window.matchMedia(mediaQuery);
70
- mql.addEventListener("change", callback);
71
- return () => mql.removeEventListener("change", callback);
72
- },
73
- [mediaQuery],
74
- );
75
-
76
- const getSnapshot = useCallback(() => {
66
+ const subscribe = (callback: () => void) => {
67
+ if (typeof window === "undefined") return () => {};
68
+ const mql = window.matchMedia(mediaQuery);
69
+ mql.addEventListener("change", callback);
70
+ return () => mql.removeEventListener("change", callback);
71
+ };
72
+
73
+ const getSnapshot = () => {
74
if (typeof window === "undefined") return false;
75
return window.matchMedia(mediaQuery).matches;
79
- }, [mediaQuery]);
76
+ };
77
78
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
79
}