@ds-pack/use-media
v1.0.0
Published
A small stateful hook for using the `window.matchMedia` API within a React component.
Downloads
2
Readme
@ds-pack/use-media
A small stateful hook for using the window.matchMedia
API within a React
component.
Installation:
yarn add @ds-pack/use-media
Usage:
import useMedia from '@ds-pack/use-media'
let mediaQuery = '(min-width: 100px)'
function Component() {
let matches = useMedia(mediaQuery)
return matches ? <div /> : null
}
Tools:
- Typescript
- Babel
- Jest