Nativebase: Header adds extra height or padding when used within SafeAreaView

Created on 8 May 2019  路  8Comments  路  Source: GeekyAnts/NativeBase

I have gone through these following points

Screen Shot 2019-05-08 at 1 37 27 PM
Screen Shot 2019-05-08 at 1 34 26 PM

Issue Description

Using Header (from native base) within SafeAreaView (from react-navigation) looks fine on iPhone XS Max but adds excess padding/height for iPhone X

node, npm, react-native, react and native-base version, expo version if used, xcode version

"react-native": "0.59.6",
"react": "16.8.6",
"native-base": "2.12.1",
"react-navigation": "3.9.1",
xcode 10.1

Expected behaviour

I expect the header & safeareaview to look the same on iPhoneX & iPhone XS Max

Actual behaviour

Header and SafeAreaView look fine on iPhone XS Max but not on iPhone X

Steps to reproduce

import React, { PureComponent } from 'react';
import { Container, Header } from 'native-base';
import { SafeAreaView } from 'react-navigation';


class Screen extends PureComponent {
  render() {
    <SafeAreaView style={{ flex: 1 }}>
      <Container>
        <Header searchBar iosBarStyle="light-content" style={{ alignItems: 'center' }} />
      </Container>
    </SafeAreaView>;
  }
}


Is the bug present in both iOS and Android or in any one of them?

just iOS

Any other additional info which would help us debug the issue quicker.

Most helpful comment

Im seeing the same issue.

All 8 comments

Have you tried without SafeAreaView? I faced this some time ago, and what I did was to use only Header, without the safe area component. Maybe works for you too if the scope is the same.

I tried using Header without SafeAreaView but it didn't give me the style I wanted for iPhone XS Max. So what I ended up doing was adding a condition wrapper based on the deviceType. If it's an iPhoneXS MAX or XR then use SafeAreaView otherwise just render without the wrapper. Works for now but hoping to optimize it later.

Thanks for the tip!

have you got proper solution? I am facing same issue.

I tried using Header without SafeAreaView but it didn't give me the style I wanted for iPhone XS Max. So what I ended up doing was adding a condition wrapper based on the deviceType. If it's an iPhoneXS MAX or XR then use SafeAreaView otherwise just render without the wrapper. Works for now but hoping to optimize it later.

Thanks for the tip!

can you share your logic ?

Im seeing the same issue.

Use forceInset={{ top: 'never' }} to remove the extra padding added to the header while keeping the safeView inset at the bottom.

  return (
      <SafeAreaView style={{flex: 1}} forceInset={{ top: 'never' }}>
        <Navigator/>
      </SafeAreaView>
  );

Had the same issue, the space between the header and the notch was too big.

What worked for me was changing the default paddingTop on the native base Header component to 0.
image

Im seeing the same issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

muthuraman007 picture muthuraman007  路  3Comments

kitsune7 picture kitsune7  路  3Comments

agersoncgps picture agersoncgps  路  3Comments

chetnadaffodil picture chetnadaffodil  路  3Comments

bsiddiqui picture bsiddiqui  路  3Comments