项目作者: bence-toth

项目描述 :
A React hook for detecting screen orientation
高级语言: JavaScript
项目地址: git://github.com/bence-toth/react-hook-screen-orientation.git
创建时间: 2019-02-19T22:32:35Z
项目社区:https://github.com/bence-toth/react-hook-screen-orientation

开源协议:GNU Lesser General Public License v3.0

下载


react-hook-screen-orientation :arrows_clockwise:

A React hook for detecting screen orientation.

Installation

Using npm:

  1. npm install --save react-hook-screen-orientation

Using yarn:

  1. yarn add react-hook-screen-orientation

Usage

  1. import React from 'react'
  2. import useScreenOrientation from 'react-hook-screen-orientation'
  3. const ComponentWithScreenOrientation = () => {
  4. const screenOrientation = useScreenOrientation()
  5. return (
  6. <p>Screen orientation is: {screenOrientation}</p>
  7. )
  8. }

Notes

The screenOrientation value provided by the hook is the type propery of a ScreenOrientation interface is always one of the following strings:

  • portrait-primary
  • portrait-secondary (meaning upside down)
  • landscape-primary
  • landscape-secondary (meaning upside down)

Contributions

Contributions are welcome. File bug reports, create pull requests, feel free to reach out at tothab@gmail.com.

Licence

LGPL-3.0