mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
30 lines
381 B
Markdown
30 lines
381 B
Markdown
# `useOrientation`
|
|
|
|
React sensor hook that tracks screen orientation of user's device.
|
|
|
|
Returns state in the following shape
|
|
|
|
```js
|
|
{
|
|
angle: 0,
|
|
type: 'landscape-primary'
|
|
}
|
|
```
|
|
|
|
|
|
## Usage
|
|
|
|
```jsx
|
|
import {useOrientation} from 'react-use';
|
|
|
|
const Demo = () => {
|
|
const state = useOrientation();
|
|
|
|
return (
|
|
<pre>
|
|
{JSON.stringify(state, null, 2)}
|
|
</pre>
|
|
);
|
|
};
|
|
```
|