I was trying to capture the hight of status bar in react native.
For which I wrote the following code
render() {
let StatusBarHeight = null
if (Platform.OS === 'ios') {
StatusBarHeight = StatusBarManager.getHeight((statusBarHeight)=>{
console.log(statusBarHeight)
return statusBarHeight
})
console.log(`This is the height of the status bar in iOS:`,StatusBarHeight)
}
}
Here, the console.log(statusBarHeight)
is coming out to be {height: 44}
which I intended to store in StatusBarHeight
but my second console.log afterwards is giving me undefined
console.log(`This is the height of the status bar in iOS:`,StatusBarHeight)
Which makes me think that StatusBarManager.getHeigh(
is async
function. So, Can someone help me figure height how can we use async-await in render of react-native