How to remove space from the top in react-drawer

4.4k views Asked by At

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

3

There are 3 answers

1
Vikas Sharma On

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>
0
Mouad Tahir On

You can use this if the status bar is hidden:

<DrawerContentScrollView 
    contentContainerStyle={{ paddingTop: 0 }}>
</DrawerContentScrollView>
0
Heron Eto On

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,
 }}
>...