useWindowDimensions

Respond to window size changes from the Dimensions module.

useWindowDimensions automatically updates width and height values when viewport size changes.

import { useWindowDimensions } from 'react-native';
const { height, scale, width } = useWindowDimensions();

API

Return value

useWindowDimensions returns the window dimension object.

height number

The height in pixels of the app viewport.

scale number

The pixel ratio of the device your app is running on.

width number

The width in pixels of the app viewport.

Updated
React Native Web for TVPortions Copyright © Nicolas Gallagher, Meta Platforms, Inc., Facebook, Inc. and affiliates, and other contributors as noted in file headers and THIRD_PARTY_NOTICES.md. Modifications and TV extensions Copyright © Harpreet Singh and contributors.