Skip to content

Commit 4af1cfb

Browse files
committed
chore: Tolerate matchMedia returning null (#4028)
1 parent 12de85f commit 4af1cfb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/internal/hooks/use-mobile/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function getIsMobile() {
2626
* wouldn't know which one of them to use).
2727
* Instead, we use the media query here in JS too.
2828
*/
29-
return window.matchMedia(`(max-width: ${mobileBreakpoint}px)`).matches;
29+
/* istanbul ignore next: matchMedia is not available in jsdom. */
30+
return window.matchMedia(`(max-width: ${mobileBreakpoint}px)`)?.matches;
3031
}
3132

3233
return getMatchingBreakpoint(window.innerWidth, ['xs']) !== 'xs';

0 commit comments

Comments
 (0)