Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

87
Vistas
React navigation shows default header with custom header only on Android

I have a weird bug on react native app, I wrote a custom header, it appears with the default header. But it's not like 2 headers on top each other, it's just the text.

enter image description here

First one is my custom header like this;

export const HeaderWithBackTitle = ({title}: {title: string}) => {
  const navigation = useNavigation();
  const HeaderOptions: NativeStackNavigationOptions = {
    headerTitle: '',
    headerStyle: {
      backgroundColor: UIColors.darkMode,
    },
    headerLeft: () => (
      <View
        style={{alignItems: 'center'}}
        row
        backgroundColor={UIColors.darkMode}>
        <PressableOpacity marginL-12 onPress={() => navigation.goBack()}>
          <Image
            style={{width: 30, height: 30}}
            source={require('../imgs/backIcon.png')}
          />
        </PressableOpacity>
        <View style={{maxWidth: '85%'}} marginL-30>
          <Text textColor darkGreyBlue regularText>
            {title}
          </Text>
        </View>
      </View>
    ),
  };
  return HeaderOptions;
};


I render it like this;

  <Stack.Screen
        name="Entries"
        component={Entries}
        options={({route}) => HeaderWithBackTitle({title: route.params?.title})}
      />

No idea how it happens.

React Native version; 0.66.3 React Navigation version: ^0.6.6

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Fixed this by doing this;

export const HeaderWithBackTitle = ({title}: {title: string}) => {
  const navigation = useNavigation();
  const HeaderOptions: NativeStackNavigationOptions = {
    // headerTitle: '',  <--- I was using this and it was working in older versions
    headerStyle: {
      backgroundColor: UIColors.darkMode,
    },
    title: '', // <---- This line should be included
    headerLeft: () => (
      <View
        style={{alignItems: 'center'}}
        row
        backgroundColor={UIColors.darkMode}>
        <PressableOpacity marginL-12 onPress={() => navigation.goBack()}>
          <Image
            style={{width: 30, height: 30}}
            source={require('../imgs/backIcon.png')}
          />
        </PressableOpacity>
        <View style={{maxWidth: '85%'}} marginL-30>
          <Text textColor darkGreyBlue regularText>
            {title}
          </Text>
        </View>
      </View>
    ),
  };
  return HeaderOptions;
};

So basically I need to give empty string to the "title" property. It's really suprising that I couldn't find any question related to this, I guess many people still using old versions.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda