I was trying to conditionally render HeaderLeft by state value, I cant able to access state value inside NavigationOptions
static navigationOptions = ({ navigation }) => ({
headerLeft: (navigation.state.searchText)? <View style={{ flexDirection: 'row', justifyContent: 'center' }}>
<TouchableOpacity onPress={() => {
// navigation.navigate('home');
alert('Coming soon ');
}}>
<Image style={{ marginLeft: 20,height:20,width:20,resizeMode:"contain" }} source={require('../assets/header_icons/three_logo.png')} />
</TouchableOpacity>
</View> : <View style={{ flexDirection: 'row', justifyContent: 'center' }}>
<TouchableOpacity onPress={() => {
// navigation.navigate('home');
alert('Coming soon');
}}>
<Image style={{ marginLeft: 20,height:20,width:20,resizeMode:"contain" }} source={require('../assets/header_icons/icon_arrow_left.png')} />
</TouchableOpacity>
</View>
});
My component did mount
componentDidMount(){
this.setState({threebool:true});
this.props.navigation.setParams({
searchText: this.state.threebool,
});
}
My constructor
constructor(props) {
super(props)
this.state = {
threebool:true,
}
}
Please let me know how to resolve this.