[英]debugging react-native TextInput behaviour
I am adding simple date masking to my react-native app. 我在我的本地应用程序中添加了简单的日期屏蔽。 It works, it seems in rnplay at https://rnplay.org/apps/3twbCw and it is not working with my app. 它可以正常工作,似乎在rnplay中位于https://rnplay.org/apps/3twbCw ,并且无法与我的应用程序一起使用。
The masking function is: 屏蔽功能为:
dateFormat(text) {
if (text.match(/^\d{2}$/) !== null) {
text += '/';
} else if (text.match(/^\d{2}\/\d{2}$/) !== null) {
text += '/';
}
this.setState({birthdate: text});
}
I apply/call this function as: 我将这个函数应用/称为:
<TextInput
key='birthdateTxt'
style={styles.formField}
returnKeyType='done'
ref={(ref) => this.birthdateInput = ref}
onFocus={() => this.inputFocused(this.birthdateInput)}
value={this.state.birthdate}
onChangeText={(text) => this.dateFormat(text)}
onSubmitEditing={() => this.register()}
/>
The function is invoked. 该函数被调用。 This is clear from the debug output. 这在调试输出中很明显。 However this.setState({birthdate: text}) does not alter the value of the TextInput. 但是,this.setState({birthdate:text})不会更改TextInput的值。 The rnplay sample seems to be doing the same thing, yet it does not exhibit the same problem. rnplay样本似乎在做相同的事情,但是并没有出现相同的问题。
What do I check? 我要检查什么?
TextInput显然在0.17中被部分破坏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.