/screen-size-query

A small, no external dependency hook that lets you know if the current viewport is mobile sized

Primary LanguageJavaScript

screen-size-query

A small, no external dependency hook that lets you know if the current viewport is mobile sized.

NPM JavaScript Style Guide

Install

npm install --save screen-size-query

Usage

import React, { Component } from 'react'
import useSizeQuery from 'screen-size-query'

class Example extends Component {
  render() {
    const { size, isMobile } = useSizeQuery();

    return (
      <>
        <h1>Size: {size}</h1>
        <h1>IsMobile: {isMobile.toString()}</h1>
      </>
    )
  }
}

License

MIT © tobycaulk