How to change the back button label, react-navigation

FR073N picture FR073N · Oct 21, 2017 · Viewed 20.1k times · Source

I'm using react-navigation, and I can't change the locale of the default 'back' button.

In my Stack Navigator, if I write down a title for the main page, and if it's not too long, it will display the page title instead of 'back'.

export const Root = StackNavigator({
Index: {
    screen: Index,
    navigationOptions: ({ navigation }) => ({
        title: "My App name", //Not working when too long
    }),
},

How can I do that ?

Default back button

Answer

bennygenel picture bennygenel · Oct 21, 2017

You can use headerBackTitle prop to control back button title.

headerBackTitle

Title string used by the back button on iOS, or null to disable label. Defaults to the previous scene's headerTitle

Example

const SomeNavigator = StackNavigator({
   Main: { screen: Main },
   Login: { 
     screen: Login,
     navigationOptions: {
       headerBackTitle: 'some label'
     }
   }
 });