最佳答案
我对React Native真的很陌生,我想知道如何隐藏/显示组件。< br / > 下面是我的测试用例:
<TextInput
onFocus={this.showCancel()}
onChangeText={(text) => this.doSearch({input: text})} />
<TouchableHighlight
onPress={this.hideCancel()}>
<View>
<Text style={styles.cancelButtonText}>Cancel</Text>
</View>
</TouchableHighlight>
我有一个TextInput
组件,我想要的是在输入获得焦点时显示TouchableHighlight
,然后在用户按下取消按钮时隐藏TouchableHighlight
。
我不知道如何“访问”;TouchableHighlight
组件,以便在函数showCancel/hideCancel
中隐藏/显示它。< br / >
此外,我如何从一开始就隐藏按钮?< / p >