use-media-query

Listen to media query matches in React

1. Install

npm i @maroun-baydoun/use-media-query
Or
yarn add @maroun-baydoun/use-media-query

2. 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)";
}

Demo