2.12.0 (Android) createNativeStackNavigator "headerTitle" / "title" not displaying when "headerLeft" is set
See original GitHub issueUsing v2.12.0, given the following example
import { Text } from "react-native";
import { createNativeStackNavigator } from "react-native-screens/native-stack";
const DashboardStack = createNativeStackNavigator();
function DashboardStackView() {
return (
<DashboardStack.Navigator screenOptions={{ headerStyle: { backgroundColor: "#DC5E5C" } }}>
<DashboardStack.Screen
name="DashboardScreen"
component={DashboardScreen}
options={({ route }) => ({
headerTitle: "Dashboard",
headerLeft: () => <LeftDrawerButton />, // "() => null" also doesn't work
})}
/>
</DashboardStack.Navigator>
);
}
const LeftDrawerButton = () => <Text>Drawer</Text>
Setting headerTitle
or title
doesn’t seem to display at all when headerLeft
is set.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
After adding image to header title header left back button not ...
try: When I stopped showing header Title Image. I works properly fine. expectation: To start work with back button along with header Title....
Read more >Configuring the header bar - React Navigation
The reason is that headerTitle is a property that is specific to stack navigators, the headerTitle defaults to a Text component that displays...
Read more >createStackNavigator - React Navigation - Netlify
Function that given HeaderProps returns a React Element, to display as a header. Make sure to set headerMode to screen as well when...
Read more >Keeping the screen in navigation drawer but hide its name ...
Screen name="FirstPage" component={FirstPage} options={{ title: 'First Page', //Set Header Title }} /> </Stack.Navigator> ); }; const secondScreenStack ...
Read more >Problem with custom header in react navigation-React Native
... Header title not changing with bottom navigation React Native Navigation v5 · KeyboardAvoidingViev not working on iOS with react navigation header and ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh, I found a solution
navigation.addListener('beforeRemove', callback)
Because it is the native behavior on Android since the title is on the left side of the header: https://github.com/software-mansion/react-native-screens/tree/master/native-stack#headerleft.
So you could use property
headerCenter
for show header title only for Android. That way will make sure consistent UI for both platform.For instance :
headerCenter: () => Platform.OS === 'android' ? <Text> Home page </Text> : null
I already try it and everything seem to be work well.