Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

27 Commits

Repository files navigation

react-hook-device-orientation 💫

A React hook for detecting device orientation.

Installation

Using npm:

npm install --save react-hook-device-orientation

Using yarn:

yarn add react-hook-device-orientation

Usage

importReactfrom'react'importuseDeviceOrientationfrom'react-hook-device-orientation'constComponentWithDeviceOrientation=()=>{constdeviceOrientation=useDeviceOrientation()return(<ul><li>Alpha: {orientation.alpha}</li><li>Beta: {orientation.beta}</li><li>Gamma: {orientation.gamma}</li><li>Absolute: {orientation.absolute ? 'yes' : 'no'}</li></ul>)}

Caveats

There are slightly different implementations of the web API responsible for accessing device orientation, and therefore the values you get from this hook might not be consistent across different browsers. Read more about this.

Contributions

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

Licence

LGPL-3.0

About

A React hook for detecting device orientation

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages