Description
This Node.js package is a collection of React hooks for using the dimensions of the screen, window, or both.
Installation
With Node.js installed, simply run the following command to add the package to your project.
npm install react-native-use-dimensions
Usage
Check out the examples below or check out the docs.
The package comes with three hooks:
- useScreenDimensions - screen dimensions
- useWindowDimensions - window dimensions, which can be separate from screen on Android
- useDimensions - screen and window dimensions
;;; const ScreenDimensions = { const height width = ; const isLandscape = width > height; return <Text> widthxheight Orientation: isLandscape ? "Landscape" : "Portrait" </Text> ;}; const WindowDimensions = { const height width = ; const isLandscape = width > height; return <Text> widthxheight Orientation: isLandscape ? "Landscape" : "Portrait" </Text> ;}; const BothDimensions = { const screen window = ; return <Text> Screen: screenwidthxscreenheight Window: windowwidthxwindowheight </Text> ;};
License
This software is released under the terms of MIT license.