Update formatting of useMediaQuery.tsx
This commit is contained in:
parent
fcd99434a0
commit
9c76a43144
1 changed files with 3 additions and 6 deletions
|
@ -6,12 +6,9 @@ const useMediaQuery = (query: string) => {
|
|||
|
||||
useEffect(() => {
|
||||
const media = window.matchMedia(query);
|
||||
if (media.matches !== matches) {
|
||||
setMatches(media.matches);
|
||||
}
|
||||
const listener = () => {
|
||||
setMatches(media.matches);
|
||||
};
|
||||
if (media.matches !== matches) setMatches(media.matches);
|
||||
const listener = () => setMatches(media.matches);
|
||||
|
||||
media.addEventListener("change", listener);
|
||||
return () => media.removeEventListener("change", listener);
|
||||
}, [matches, query]);
|
||||
|
|
Loading…
Reference in a new issue