Skip to content

Commit

Permalink
[@mantine/hooks] use-media-query: Check for window on SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
Rouby authored May 13, 2021
1 parent d0303f3 commit d30915c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mantine-hooks/src/use-media-query/use-media-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function attachMediaListener(query: MediaQueryList, callback: MediaQueryCallback

export function useMediaQuery(query: string) {
const [matches, setMatches] = useState(() => {
if ('matchMedia' in window) {
if (typeof window !== 'undefined' && 'matchMedia' in window) {
return window.matchMedia(query).matches;
}
return false;
Expand Down

0 comments on commit d30915c

Please sign in to comment.