@maroun-baydoun/use-media-query
v1.0.0
Published
Listen to media query matches in React
Maintainers
Readme
@maroun-baydoun/use-media-query
Listen to media query matches in React
Install
npm i @maroun-baydoun/use-media-queryOr
yarn add @maroun-baydoun/use-media-queryexpects
react >= 16.8.0to be installed as a peer dependency.
Use
import useMediaQuery from "@maroun-baydoun/use-media-query";
const MyComponent = () => {
const matches = useMediaQuery("only screen and (min-width: 1024px)");
return matches ? "It matches!" : "No match (yet)";
}Browser Compatibility
This library relies on the window.matchMedia API. Compatible browsers can be found here.
