use-mq

matchMedia React hook

Usage no npm install needed!

<script type="module">
  import useMq from 'https://cdn.skypack.dev/use-mq';
</script>

README

use-mq

Build Status Greenkeeper badge

matchMedia React hook

Installation

  • npm: npm install --save use-mq
  • yarn: yarn add use-mq

Usage

import { useMQ } from 'use-mq';

const MyComponent = () => {
  const matches = useMQ('(min-width: 400px)');

  return matches
    ? <div>Matches!</div>
    : null;
}