0
我有一个TextInput,其样式根据状态发生更改。React Native:TextInput在样式发生变化时丢失文本
<TextInput
autoCapitalize="characters"
defaultValue={this.props.name}
onChangeText={(text) => { this.handleChangeText(text); }}
onEndEditing={this.handleTextSubmit}
placeholder={this.props.dictionary.Identification__placeholder}
placeholderTextColor={color.WHITE}
ref={(component) => { this.textInput = component; }}
style={[
defaultStyles.input,
styles.input,
this.state.keyboardIsVisible && styles.inputSelected,
]}
underlineColorAndroid="rgba(0,0,0,0)"
/>
问题是当样式改变时,它将擦除TextInput中的当前值。有没有办法解决这个问题?
handleTextChange更新状态中的值。 'value = {this.state.inputText}'解决了我的问题。谢谢,我没有这样做。 –