Skip to content

Commit

Permalink
protect window.matchMedia access
Browse files Browse the repository at this point in the history
  • Loading branch information
brenthagen committed Feb 12, 2024
1 parent eed697a commit c68e0ed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions components/src/ui-style-constants/responsiveness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
// is precisely 600x1024
export const touchscreenMediaQuerySpecs = '(height: 600px) and (width: 1024px)'

export const isTouchscreen = window.matchMedia(touchscreenMediaQuerySpecs)
.matches
export const isTouchscreen =
typeof window === 'object' && window.matchMedia != null
? window.matchMedia(touchscreenMediaQuerySpecs).matches
: false

0 comments on commit c68e0ed

Please sign in to comment.