react-native-hooks / dimensions

React Native hook for Dimensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@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

About

React Native hook for Dimensions

License:MIT License


Languages

Language:JavaScript 41.8%Language:Objective-C 31.7%Language:Python 15.8%Language:Java 10.8%