1.4.0 • Published 2 years ago

react-use-match-media v1.4.0

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

react-use-match-media

Simple window.matchMedia React hook.

Usage

useMatchMedia(mediaQueryString[, initialState])

Parameters

  • mediaQueryString string representing the media query to parse.
  • initialState (optional) boolean initial state to return if window.matchMedia is not supported, i.e. SSR.

Return value

Boolean that returns true if the document currently matches the media query list.

Example

import useMatchMedia from 'react-use-match-media';

const Example = (props) => {
  const isWideViewport = useMatchMedia('(min-width: 600px)');

  return <div>{isWideViewport ? 'Wide' : 'Narrow'}</div>;
};

More examples can be found in the COOKBOOK.md.

Requirements

Requires a minimum of React version 16.8.0 for the Hooks API.

1.4.0

2 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.0.1

4 years ago