This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

react-hook-resolution

1.1.0 • Public • Published

react-hook-resolution

Get the screen resolution of your page with a simple react hook

NPM JavaScript Style Guide

Install

npm install --save react-hook-resolution

Usage

See this example for live demo

import React, { Component } from 'react';

import { useResolution } from 'react-hook-resolution';

class Example extends Component {
  const resolution = useResolution();

  render() {
    return <div>
        {resolution.mobile && 'I am on mobile !'}
    </div>
  }
}

Pass config to override the default breakpoints

import React, { Component } from 'react';

import { useResolution } from 'react-hook-resolution';

class Example extends Component {
  const resolution = useResolution({
                                           desktop: 1200,
                                           tablet: 900,
                                           mobile: 0
                                       });

  render() {
    return <div>
        {resolution.mobile && 'I am on mobile !'}
    </div>
  }
}

License

MIT © Keized

Readme

Keywords

Package Sidebar

Install

npm i react-hook-resolution

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

10.9 kB

Total Files

6

Last publish

Collaborators

  • keized