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
Edit
React Native for WebCopyright © Nicolas Gallagher and Meta Platforms, Inc.