Skip to content

Commit ad8f354

Browse files
committed
move server snapshot outside of the hook to use the same reference.
1 parent 0124d18 commit ad8f354

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

resources/js/hooks/use-mobile.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ function mediaQueryListener(callback: (event: MediaQueryListEvent) => void) {
1515
};
1616
}
1717

18-
function isSmallerThanBreakpoint() {
18+
function isSmallerThanBreakpoint(): boolean {
1919
return mql()?.matches || false;
2020
}
2121

22+
const getServerSnapshot = (): boolean => false;
23+
2224
export function useIsMobile() {
2325
return useSyncExternalStore(
2426
mediaQueryListener,
2527
isSmallerThanBreakpoint,
26-
() => false,
28+
getServerSnapshot,
2729
);
2830
}

0 commit comments

Comments
 (0)