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 .
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: UseaddEventListenerV2() instead.
change: Fires when a property within theDimensionsobject changes. The argument to the event handler is aDimensionsValuetype object.
addEventListenerV2
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
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:

