Skip to content

carloluis/use-media-query-hook

Repository files navigation

use-media-query-hook

React hook to check when a media query result changes

GitHub license npm Build Status PeerDependencies

Demo page

Install

yarn add use-media-query-hook

Usage

import React from 'react';
import useMediaQuery from 'use-media-query';

const App = () => {
  const isMobile = useMediaQuery('(max-width: 425px)')
  return (
    <h1>
      { isMobile ? '📱' : '💻' }
    </h1>
  );
}

Check MDN docs on using media queries