React Native hook for Dimensions
$ yarn add @rnhooks/dimensions
import useDimensions from '@rnhooks/dimensions';
function App() {
const { fontScale, width, height, scale } = useDimensions('window');
return (
<View style={styles.container}>
<Text style={styles.type}>{`Width: ${width}`}</Text>
<Text style={styles.type}>{`Height: ${height}`}</Text>
<Text style={styles.type}>{`Font Scale: ${fontScale}, Scale: ${scale}`}</Text>
</View>
);
}
Name | Default | Type | Description |
---|---|---|---|
window / screen |
null |
string | Type window or screen Dimension |
Name | Type | Default | Description |
---|---|---|---|
width | number | null |
Width of the Screen |
height | number | null |
Height of the Screen |
fontScale | number | null |
Font Scale of the Screen |
scale | number | null |
Scale of the Screen |
- @pritishvaidya The main author.
Feel free to contact me or create an issue