@phenomenon-hooks/use-media-query
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

useMediaQuery


Installation

yarn add @phenomenon-hooks/use-media-query

or

npm i @phenomenon-hooks/use-media-query

Usage

import React from 'react';
import { useMediaQuery } from '@phenomenon-hooks/use-media-query';

const Component: React.FC = () => {
    const isMobile = useMediaQuery('(max-width: 768px)');

    return (
        <div>
            <p>Is mobile: {isMobile ? 'yes' : 'no'}</p>
        </div>
    );
};

Anatomy

const isMediaQueryTrue = useMediaQuery('(max-width: 768px)');

Arguments

Argument Type Description
query string Media query string. (e.g. '(max-width: 768px)' or '(min-width: 768px)')

Returns

Return value Type Description
isMediaQueryTrue boolean Does media query match or not.

Readme

Keywords

none

Package Sidebar

Install

npm i @phenomenon-hooks/use-media-query

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

7.53 kB

Total Files

8

Last publish

Collaborators

  • mykola.kolomoyets