【发布时间】:2018-01-10 13:33:27
【问题描述】:
朋友,当用户单击组件(视图)必须隐藏的按钮并再次单击应该显示的按钮时,我在运行时遇到了隐藏和显示的问题。
我的密码:
constructor(props) {
super(props);
this.state = {
isModalVisible : false,
};
}
callFunc(){
if(this.isModalVisible){
this.setState({isModalVisible:false});
}else{
this.setState({isModalVisible:true});
}
}
render() {
return (
<View style = {styles.companyScroll}>
<Button
onPress={this.callFunc}
title="Learn More"
color="#841584"
accessibilityLabel="Learn more about this purple button"
/>
{this.state.isModalVisible && <Picker style ={{backgroundColor : 'white'}}
selectedValue={this.state.language}
onValueChange={(itemValue, itemIndex) => this.setState({language: itemValue})}>
<Picker.Item label="Java" value="java" />
<Picker.Item label="JavaScript" value="js" />
</Picker>
</View>
)
}
我想喜欢下面的图片。
【问题讨论】:
标签: reactjs react-native react-native-android react-native-ios react-animated