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(() => {
|
useEffect(() => {
|
||||||
const media = window.matchMedia(query);
|
const media = window.matchMedia(query);
|
||||||
if (media.matches !== matches) {
|
if (media.matches !== matches) setMatches(media.matches);
|
||||||
setMatches(media.matches);
|
const listener = () => setMatches(media.matches);
|
||||||
}
|
|
||||||
const listener = () => {
|
|
||||||
setMatches(media.matches);
|
|
||||||
};
|
|
||||||
media.addEventListener("change", listener);
|
media.addEventListener("change", listener);
|
||||||
return () => media.removeEventListener("change", listener);
|
return () => media.removeEventListener("change", listener);
|
||||||
}, [matches, query]);
|
}, [matches, query]);
|
||||||
|
|
Loading…
Reference in a new issue