1.0.9 • Published 2 years ago
react-use-device-orientation v1.0.9
React useDeviceOrientation Hook
Install
npm i react-use-device-orientation
Usage
- Import
useDeviceOrientationhook. - Call
requestAccesswhich prompts the use to grant permission on iOS. - Use the
orientationdata.
import { useDeviceOrientation } from 'react-use-device-orientation'
// ...
const { orientation, requestAccess, revokeAccess, error } = useDeviceOrientation()To obtain absolute orientation pass "absolute" to the hook as a parameter.
const { orientation, requestAccess, revokeAccess, error } = useDeviceOrientation('absolute')More Info
https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent#browser_compatibility