Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Skip to main content
useWindowDimensions is the preferred API for React components. Unlike Dimensions, it updates as the window’s dimensions update. This works nicely with the React paradigm. Deprecated: useKeplerWindowDimensions is the preferred API for React Native for Vega applications. Unlike useWindowDimensions, it updates when any application component’s window dimension update. useKeplerWindowDimensionsV2 use this hook instead which updates the dimensions based on root tag to handle multiple interactive component and multiple instances .
You can get the application window’s width and height using the following code:
React Native for Vega applications can get the dimensions for all application component windows using the following code:
DisplayMetricsKepler Type:
If your React Native for Vega application only has a single application component, you can just rely on Dimensions.get('window'). If you have more than one application component you will need to use Dimensions.get('windows') and identify the dimensions for the particular component you are interested in. When there is more than one Vega app component, Dimensions.get(‘window’) returns dimensions for the first component created in the app process. Although dimensions are available immediately, they may change (e.g due to device rotation, foldable devices etc) so any rendering logic or styles that depend on these constants should try to call this function on every render, rather than caching the value (for example, using inline styles rather than setting a value in a StyleSheet). If you are targeting foldable devices or devices which can change the screen size or app window size, you can use the event listener available in the Dimensions module as shown in the below example.

Example Vega

Reference

Methods

addEventListener

Deprecated: Use addEventListenerV2() instead.
Add an event handler. Supported events:
  • change: Fires when a property within the Dimensions object changes. The argument to the event handler is a DimensionsValue type object.

addEventListenerV2

Add an event handler. addEventListenerV2 is based on root tag which supports multiple instances and multiple interactive components. Supported events:
  • didUpdateDimensions: Fires when a property within the Dimensions object changes. The argument to the event handler is a DimensionsValue type object.

get

Initial dimensions are set before runApplication is called so they should be available before any other require’s are run, but may be updated later. Example: const {height, width} = Dimensions.get('window'); Vega example:
Parameters:

Type definitions

DimensionsValue

Properties:

ScaledSize

Properties:
Last modified on December 10, 2025