@rnhooks/device-orientation
Version:
React Native hook for Device Orientation
35 lines (24 loc) • 1.24 kB
Markdown
# /device-orientation [](https://travis-ci.com/react-native-hooks/device-orientation) [](https://codeclimate.com/github/react-native-hooks/device-orientation/maintainability)
> React Native hook for [device orientation](https://facebook.github.io/react-native/docs/dimensions#docsNav)
[Demo](./demo-orientation.gif)
### Installation
```bash
yarn add /device-orientation
```
### Usage
```js
import useDeviceOrientation from '/device-orientation';
function App() {
const deviceOrientation = useDeviceOrientation();
return (
<View style={styles.container}>
<Text style={styles.type}>Device orientation is:</Text>
<Text style={styles.effectiveType}>{deviceOrientation}</Text>
</View>
);
}
```
### Output
| Name | Values | Description |
| ----------------- | ----------------------- | ---------------------------------------------- |
| deviceOrientation | `portrait`, `landscape` | possible values are `portrait` and `landscape` |