Skip to content

Commit 33d301a

Browse files
committed
Update use-mobile.tsx
1 parent b85116d commit 33d301a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

resources/js/hooks/use-mobile.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
66

77
function mediaQueryListener(callback: (event: MediaQueryListEvent) => void) {
88
mql.addEventListener('change', callback);
9+
910
return () => {
1011
mql.removeEventListener('change', callback);
1112
};
1213
}
1314

1415
export function useIsMobile() {
1516
return useSyncExternalStore(
16-
mediaQueryListener, // React won't resubscribe for as long as you pass the same function
17-
() => window.innerWidth < MOBILE_BREAKPOINT, // How to get the value on the client
18-
() => false, // How to get the value on the server
17+
mediaQueryListener,
18+
() => window.innerWidth < MOBILE_BREAKPOINT,
1919
);
2020
}

0 commit comments

Comments
 (0)