1.0.4 • Published 5 years ago
@artifak/usematchmedia v1.0.4
@artifak/usematchmedia
A React hook that allows you to perform media queries within your React component.
Installation
Yarn
yarn add @artifak/usematchmediaNPM
npm install @artifak/usematchmediaUsage
import { useMatchMedia } from 'artifak';
import { ExampleMobile } from './ExampleMobile';
import { ExampleDesktop } from './ExampleDesktop';
export function Nav() {
const matchedMobile = useMatchMedia('(hover: none)');
return (
<>
{matchedMobile && <ExampleMobile />}
{!matchedMobile && <ExampleDesktop />}
</>
);
}