Javascript 调试本地文本输入行为
我正在向react原生应用程序添加简单的日期屏蔽。它工作,它似乎在rnplay中,但它不适用于我的应用程序 掩蔽功能是:Javascript 调试本地文本输入行为,javascript,ios,react-native,Javascript,Ios,React Native,我正在向react原生应用程序添加简单的日期屏蔽。它工作,它似乎在rnplay中,但它不适用于我的应用程序 掩蔽功能是: dateFormat(text) { if (text.match(/^\d{2}$/) !== null) { text += '/'; } else if (text.match(/^\d{2}\/\d{2}$/) !== null) { text += '/'; } this.setState({birthdate: text}); }
dateFormat(text) {
if (text.match(/^\d{2}$/) !== null) {
text += '/';
} else if (text.match(/^\d{2}\/\d{2}$/) !== null) {
text += '/';
}
this.setState({birthdate: text});
}
我将此函数应用/调用为:
<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()}
/>
this.birthdateInput=ref}
onFocus={()=>this.inputFocused(this.birthdateInput)}
值={this.state.birthdate}
onChangeText={(文本)=>this.dateFormat(文本)}
onSubmitEditing={()=>this.register()}
/>
调用该函数。从调试输出中可以清楚地看到这一点。但是,此.setState({birthdate:text})不会更改TextInput的值。rnplay示例似乎在做相同的事情,但它并没有表现出相同的问题
我应该检查什么?TextInput在0.17中显然部分中断。这个问题发生在应用程序构建在0.17上,而rnplay运行在0.13rc上。到目前为止,这是我注意到的唯一可能的原因。