Я пытался условно визуализировать HeaderLeft по значению состояния, я не могу получить доступ к значению состояния внутри 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>
});
Мой компонент смонтировал
componentDidMount(){
this.setState({threebool:true});
this.props.navigation.setParams({
searchText: this.state.threebool,
});
}
Мой конструктор
constructor(props) {
super(props)
this.state = {
threebool:true,
}
}
Пожалуйста, дайте мне знать, как решить эту проблему.