Skip to content

Latest commit

 

History

History

use-media-query

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

useMediaQuery

A React hook that monitors whether a specific media query matches the current viewport.

Usage

import React from 'react';
import { useMediaQuery } from '@codiume/hooks';

const ExampleComponent = () => {
  const isDesktop = useMediaQuery('(min-width: 768px)');

  return (
    <div>
      {isDesktop ? (
        <p>You are on a desktop-sized screen!</p>
      ) : (
        <p>You are on a mobile-sized screen!</p>
      )}
    </div>
  );
};