Search code examples
react-native

How to remove the back button in the header react native


I want to remove the button back, but leave the header.

enter image description here

My component is as follows. I want to leave the title, and I don’t need the back button.

import React from 'react';
import { View } from 'react-native';


export const TrucksScreen = () => {
    return (
        <View>
           ....
        </View>
    );
});

TrucksScreen.navigationOptions = {
    headerTitle: 'Trucks Screen',
};

How can I remove the button back?


Solution

  • Using headerLeft: null will be deprecated in future versions.

    Instead use a function like so :

    TrucksScreen.navigationOptions = {
        headerTitle: 'Trucks Screen',
        headerLeft: () => {
          return null;
        },
    };
    

    Cheers !