Is there a way to override Expo Constants?

I am using Expo with react-navigation and experiencing an issue with header’s height on android.

It seems the header height is set to 56 (android) + 24 (global.Expo.Constants.statusBarHeight).

I want statusBarHeight to be set to 0 so that the header height is 56 not 80 (56 + 24)

Then I found this snippet from react-native-safe-area-view where for Expo projects, the header picks up the preset height value from the Constants.

https://github.com/react-native-community/react-native-safe-area-view/blob/master/index.js#L89

if (Platform.OS === 'android') {
  if (global.Expo) {
    return global.Expo.Constants.statusBarHeight;
  } else {
    return 0;
  }
}

I think if I can just simply override global.Expo.Constants.statusBarHeight to 0. then I’ll have the header in my desired height.

But I don’t know if that is doable.

Let me know what you think.

Thank you in advance.

import { SafeAreaView } from 'react-navigation';
SafeAreaView.setStatusBarHeight(0);
1 Like

Thank you! I did exactly that and it now works as expected.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.