Open In App

How to use useMediaQuery Component in ReactJS ?

The useMediaQuery Component is a CSS media query hook for React. Using this functionality, we can write our own CSS media query for which this function looks for a match, and it renders if the query matches. Material UI for React has this component available for us, and it is very easy to integrate. We can use the following approach in ReactJS to use useMediaQuery Component.

Creating React Application And Installing Module:



npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

Reference: https://material-ui.com/components/use-media-query/

Article Tags :