react-native-dimensions-hooks
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0 • Public • Published

    React Native Dimensions Hooks

    Hooks to wrap the React Native Dimensions API for Native and React Native Web.

    They use listeners under the hood, so they will update on window and screen size changes.

    Demo

    Usage:

    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.

    import {
      useWindowDimensions,
      useScreenDimension,
    } from 'react-native-dimensions-hooks';
     
    ...
     
    const useScreenDimension = useScreenDimension();
    const windowDimensions = useWindowDimensions();

    Install

    npm i react-native-dimensions-hooks

    DownloadsWeekly Downloads

    272

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    14.2 kB

    Total Files

    15

    Last publish

    Collaborators

    • avatar