6

I am using it and i am getting white space at the top. Can any provide me detail to remove this white space from top. @react-navigation/drawerenter image description here

Rover
  • 661
  • 2
  • 18
  • 39

3 Answers3

11

You can use this if the status bar is hidden:

<DrawerContentScrollView 
    contentContainerStyle={{ paddingTop: 0 }}>
</DrawerContentScrollView>
Mouad Tahir
  • 450
  • 6
  • 9
8

In DrawerContentScrollView there is a default padding of 4 was added in @react-navigation/drawer code so to remove this just pass paddingTop prop in contentContainerStyle.

const insets = useSafeArea();

<DrawerContentScrollView
    contentContainerStyle={{
       paddingTop: insets.top,
    }}
   {...props}>
</DrawerContentScrollView>
Vikas Sharma
  • 685
  • 8
  • 18
  • Thanks, I'd guessed there was some padding but didn't know there was a `contentContainerStyle` property – eckc Apr 20 '21 at 04:20
4

Just to add, I had the same problem and useSafeArea is deprecated. I managed using useSafeAreaInsets.

import { useSafeAreaInsets } from 'react-native-safe-area-context';

...<DrawerContentScrollView 
  style={styles.container} 
  contentContainerStyle={{
    paddingTop: insets.top,
 }}
>...
Heron Eto
  • 61
  • 2