Skip to content

Commit 7732c0c

Browse files
committed
move snapshot function from component
1 parent 33d301a commit 7732c0c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

resources/js/hooks/use-mobile.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ function mediaQueryListener(callback: (event: MediaQueryListEvent) => void) {
1212
};
1313
}
1414

15+
function isSmallerThanBreakpoint() {
16+
return window.innerWidth < MOBILE_BREAKPOINT;
17+
}
18+
1519
export function useIsMobile() {
16-
return useSyncExternalStore(
17-
mediaQueryListener,
18-
() => window.innerWidth < MOBILE_BREAKPOINT,
19-
);
20+
return useSyncExternalStore(mediaQueryListener, isSmallerThanBreakpoint);
2021
}

0 commit comments

Comments
 (0)