I am using react native navigation and I need to update back button design which I have achieved by following code
static navigationOptions = {
title: '',
headerStyle: {
backgroundColor: '#544849',
},
tintColor: 'transparent',
headerLeft: <TouchableOpacity onPress={() => this.props.navigation.goBack()}><Image source={require('../../img/close.png')} style={{marginTop: 10, marginLeft:10}} /></TouchableOpacity>
};
But this way I get error undefined is not an object(evaluating r.props.navigation)
back button does nothing without onPress.
Acourding to docs for NavigationOptions you can change your code like below.
static navigationOptions = ({ navigation, screenProps }) => ({
title: '',
headerStyle: {
backgroundColor: '#544849',
},
tintColor: 'transparent',
headerLeft: <TouchableOpacity onPress={() => navigation.goBack()}><Image source={require('../../img/close.png')} style={{marginTop: 10, marginLeft:10}} /></TouchableOpacity>
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With