问题
I'm developing a react native module for an existing mobile app, using react-navigation component:
import { StackNavigator } from 'react-navigation';
....
const App = StackNavigator({
Main: {
screen: Main,
navigationOptions: {
headerBackTitle: null,
}
},
Details: {
screen: Details,
navigationOptions: {
headerBackTitle: null,
}
}
});
In Main index I render a simple button that on click do this:
render() {
const navigation = this.props.navigation;
return (
<View>
<Button
title="Go to details"
onPress={() => { navigation.navigate("Details") }}
/>
</View>
);
}
That's it.
The issue is that the navigation back button is invisible (see image):
This happen after this operations:
Copying bundle in android project .
react-native bundle --platform android \ --dev false --entry-file index.js --bundle-output ../MyApp/app/src/main/assets/index.android.bundle \ --assets-dest ../MyApp/app/src/main/
Launching app from Android studio
Any advice?
回答1:
navigationOptions: ({ navigation }) => ({
headerLeft: drawerButton(navigation)
})
const drawerButton = navigation => (
<TouchableOpacity onPress={() => navigation.navigate("DrawerToggle")}>
<Image source={Your.image} style={Your.Style} />
</TouchableOpacity>
);
Use this code!
来源:https://stackoverflow.com/questions/51540388/react-native-back-button-missing-icon