react-native-dimensions-hooks
Version:
Hooks to wrap the React Native Dimensions API for React Native and React Native Web
39 lines (28 loc) • 895 B
Markdown
for Native and React Native Web.
They use listeners under the hood, so they will update on window and screen size changes.
[ ](https://rjerue.github.io/react-native-dimensions-hooks)
```jsx
import React from 'react';
import useDimensions from 'react-native-dimensions-hooks';
export default () => {
const { window, screen } = useDimensions();
return (
<div>
<div>Window {JSON.stringify(window)}</div>
<div>Screen {JSON.stringify(screen)}</div>
</div>
);
};
```
Window or screen may be also imported individually by `useWindowDimensions` or `useScreenDimension`.
```jsx
import {
useWindowDimensions,
useScreenDimension,
} from 'react-native-dimensions-hooks';
...
const useScreenDimension = useScreenDimension();
const windowDimensions = useWindowDimensions();
```
Hooks to wrap the React Native Dimensions API