React-native-screens: Redundant space between StatusBar and Stack header on Android

Created on 16 Jul 2020  路  1Comment  路  Source: software-mansion/react-native-screens

Hi, after updating the expo to the version 38, I encountered with a strange issue on Android device. (Before SDK 38, everything worked as expected)

Whenever I use the StatusBar component from ReactNative it adds additional space between stack header and status bar.

With StatusBar component
image

Without StatusBar component
image

The source code looks like this

const Stack = createNativeStackNavigator();

export default App() {
  return (
    <SafeAreaProvider initialMetrics={initialWindowMetrics}>
      <StatusBar />
      <Stack.Navigator>
        <Stack.Screen name='Screen1' component={Screen1} />
      </Stack.Navigator>
    </SafeAreaProvider>
  )
}

I'm not sure if this kind of issue is related to the react-native-screens or to the react-navigation with react-native-safe-area-context.

I was trying to create snack example but faced with issue which complains about react-native-screens imports.

image

Most helpful comment

I resolved my question by reading the release notes of the react-native-screens.

It also adds #545 by @brentvatne, which introduces additional padding to the header, which is a BREAKING CHANGE and will cause the header to have too much top padding in case of not having a translucent status bar.

See https://github.com/software-mansion/react-native-screens/releases/tag/2.9.0

So, I just set the translucent prop to true on the StatusBar component.

const Stack = createNativeStackNavigator();

export default App() {
  return (
    <SafeAreaProvider initialMetrics={initialWindowMetrics}>
      <StatusBar translucent={true} /> {/* <--- Here */}
      <Stack.Navigator>
        <Stack.Screen name='Screen1' component={Screen1} />
      </Stack.Navigator>
    </SafeAreaProvider>
  )
}

I close this issue

>All comments

I resolved my question by reading the release notes of the react-native-screens.

It also adds #545 by @brentvatne, which introduces additional padding to the header, which is a BREAKING CHANGE and will cause the header to have too much top padding in case of not having a translucent status bar.

See https://github.com/software-mansion/react-native-screens/releases/tag/2.9.0

So, I just set the translucent prop to true on the StatusBar component.

const Stack = createNativeStackNavigator();

export default App() {
  return (
    <SafeAreaProvider initialMetrics={initialWindowMetrics}>
      <StatusBar translucent={true} /> {/* <--- Here */}
      <Stack.Navigator>
        <Stack.Screen name='Screen1' component={Screen1} />
      </Stack.Navigator>
    </SafeAreaProvider>
  )
}

I close this issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thomasgosse picture thomasgosse  路  4Comments

thorbenandresen picture thorbenandresen  路  4Comments

joshua-augustinus picture joshua-augustinus  路  4Comments

ukasiu picture ukasiu  路  4Comments

Kinark picture Kinark  路  4Comments