Constants
React Native Navigation exposes a set of constants which can be used to get the dimensions of various navigation elements on the screen: StatusBar, TopBar and BottomTabs.
#
When are constants evaluatedSome of the values exposed through the constants API are actually evaluated only after the UI is created (setRoot
has been called) and therefore are not accessible through static getters.
For example, if you need to get the height of the BottomTabs, you'll first need to have BottomTabs visible on the screen and only then retrieve their height via the constants API.
important
We recommend you don't cache the actual constants object returned by await Navigation.constants()
as it might not be accurate later on when, for example, a new root is set or orientation changes.
#
APIAs explained above, constants are evaluated in native each time the API is invoked. That's why Navigation.constants()
returns a promise and the use is as follows: