@artifak/usematchmedia

1.0.4 • Public • Published

@artifak/usematchmedia

A React hook that allows you to perform media queries within your React component.

Installation

Yarn

yarn add @artifak/usematchmedia

NPM

npm install @artifak/usematchmedia

Usage

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 />}
    </>
  );
}

Readme

Keywords

none

Package Sidebar

Install

npm i @artifak/usematchmedia

Weekly Downloads

3

Version

1.0.4

License

MIT

Unpacked Size

7.2 kB

Total Files

11

Last publish

Collaborators

  • heyjules