1.1.0 • Published 9 months ago

react-hook-resolution v1.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
9 months ago

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

1.1.0

9 months ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago