fix: Severla context menus miss-positioned fix: Search filters not large enough on mobile fix: Deep black background on mobile to match native apps fix: Sticky document header allowing horizontal scrolling on mobile
21 lines
514 B
JavaScript
21 lines
514 B
JavaScript
// @flow
|
|
import { useState, useEffect } from "react";
|
|
|
|
export default function useMediaQuery(query: string): boolean {
|
|
const [matches, setMatches] = useState<boolean>(false);
|
|
|
|
useEffect(() => {
|
|
const media = window.matchMedia(query);
|
|
if (media.matches !== matches) {
|
|
setMatches(media.matches);
|
|
}
|
|
const listener = () => {
|
|
setMatches(media.matches);
|
|
};
|
|
media.addListener(listener);
|
|
return () => media.removeListener(listener);
|
|
}, [matches, query]);
|
|
|
|
return matches;
|
|
}
|