use-mediaquery

1.0.1 • Public • Published

use-mediaquery

React custom hook for matchMedia, allowing you to respond to media queries.

Installation

npm install use-mediaquery
yarn add use-mediaquery

Usage

import React from "react";
import useMediaQuery from "use-mediaquery";
 
const Component = () => {
  const matches = useMediaQuery("(min-width: 40em)");
 
  <p>
    Matches? <strong>{matches.toString()}</strong>
  </p>;
};

Example

https://codesandbox.io/s/o4n5mxqwvq

License

MIT

Package Sidebar

Install

npm i use-mediaquery

Weekly Downloads

96

Version

1.0.1

License

MIT

Unpacked Size

2.44 kB

Total Files

4

Last publish

Collaborators

  • wickynilliams