Skip to content

Commit

Permalink
Merge branch 'main' into feat/asChild-clone
Browse files Browse the repository at this point in the history
  • Loading branch information
mimarz authored Apr 10, 2024
2 parents 682d7c8 + 06875a4 commit d4037ff
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/react-old/src/hooks/useMediaQuery.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { useEffect, useState } from 'react';

export function useMediaQuery(query: string): boolean {
const getMatches = (query: string): boolean =>
window?.matchMedia(query).matches ?? false;
const getMatches = (query: string): boolean => {
/* Check if window is defined, if not - return false */
if (typeof window === 'undefined') {
return false;
}

return window?.matchMedia(query).matches ?? false;
};

const [matches, setMatches] = useState<boolean>(getMatches(query));

Expand Down

0 comments on commit d4037ff

Please sign in to comment.