use-match-media-query

Match Media as a React hook!

Usage no npm install needed!

<script type="module">
  import useMatchMediaQuery from 'https://cdn.skypack.dev/use-match-media-query';
</script>

README

use-match-media-query

package version package downloads standard-readme compliant package license make a pull request JavaScript Style Guide

Match Media as a React hook!

Table of Contents

Usage

import {useMatchMediaQuery} from 'use-match-media-query'

const Comp = () => {
    const isMobile = useMatchMediaQuery('screen and (max-width: 60em')
    return isMobile ? 'on mobile' : 'not on mobile'
}

Install

This project uses node and npm.

$ npm install use-match-media-query
$ # OR
$ yarn add use-match-media-query

Safari

Having issues on Safari? You are not alone!.

Polyfills

Contribute

  1. Fork it and create your feature branch: git checkout -b my-new-feature
  2. Commit your changes: git commit -am "Add some feature"
  3. Push to the branch: git push origin my-new-feature
  4. Submit a pull request

License

MIT