Skip to content

Commit c54e8ec

Browse files
committed
fix: add a browser checkpoint
1 parent 8d2bdfa commit c54e8ec

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}

src/utils/isBrowser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const isBrowser = typeof window !== 'undefined'

src/utils/makeMediaQueryList.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
import { isBrowser } from './isBrowser'
2+
13
export default function makeMediaQueryList(breakpoints: number[]) {
24
return breakpoints.map((breakpoint: number, index: number) => {
35
const maxWidth = breakpoints[index + 1]
6+
7+
if (!isBrowser) return
8+
49
return window.matchMedia(
510
`(min-width: ${breakpoint}px) ${
611
maxWidth ? `and (max-width: ${maxWidth - 1}px)` : ''

0 commit comments

Comments
 (0)