Skip to content

react-native-hooks/dimensions

Repository files navigation

@rnhooks/dimensions Build Status Maintainability module formats: umd, cjs, esm

React Native hook for Dimensions

Installation

$ yarn add @rnhooks/dimensions

Usage

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>
  );
}

Input

Name Default Type Description
window / screen null string Type window or screen Dimension

Output

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

Contribution

Questions

Feel free to contact me or create an issue