Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-use-media-query

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-use-media-query

`react-use-media-query` is a React Hook that help you to render content conditionally based on a media query, by listening for matches to a [CSS media query](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries).

  • 1.0.3
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-use-media-query

react-use-media-query is a React Hook that help you to render content conditionally based on a media query, by listening for matches to a CSS media query.

Instalation

Using npm:

npm i react-use-media-query

Using yarn:

yarn add react-use-media-query

Usage

import React from "react";
import useMediaQuery from "react-use-media-query";

const App = () => {
  const isMobile = useMediaQuery("(max-width: 480px)");

  return (
    <>
      {isMobile ? <p>mobile</p> : <p>desktop</p>}
    </>
  )
};

Params

useMediaQuery(query, defaultMatch)

query: can be a string, an object e.g. {minWidth: 100, maxWidth: 200}, {screen: true}, {minWidth: 100, maxWidth: '20em'} or an array of objects e.g. [{screen: true, minWidth: 100}, {handheld: true, orientation: 'landscape'}].

defaultMatch: is the default boolean returned value.

Keywords

FAQs

Package last updated on 04 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc