我有TextInput
组件,在其引用上调用clear()
时不会清除。奇怪的是,我在另一个组件中还有其他TextInput
,并且在那儿工作得很好。知道会是什么吗?
无可用代码:
<View style={styles.addLinkContainer}>
<TextInput
autoCorrect={false}
ref={input => { this.txtInput = input }}
style={styles.linkInput}/>
<TouchableOpacity onPress={() => {this.foo(this.fee)}}>
<IconFA name="arrow-right" size={scale(30)} color="#a6a6a6"/>
</TouchableOpacity>
</View>
foo = (url) => {
...
this.txtInput.clear()
this.txtInput.blur()
...
}
在另一个组件中的工作代码:
<KeyboardAvoidingView behavior="padding" enabled style={{width:'100%'}}>
<View style={{flex:1, flexDirection: 'row'}}>
<TextInput
multiline={true}
ref={input => this.input = input}
style={[newStyle]}
onChangeText={(text) => this.commentPlaceHolder = text}
value={this.commentPlaceHolder}
/>
<TouchableOpacity onPress={() => this.foo()}>
<IconFA name="rocket" size={scale(30)} color="#a6a6a6"/>
</TouchableOpacity>
</View>
</CardAction>
</KeyboardAvoidingView>
foo = () => {
...
this.input.clear()
...
}