当按下输入文本到3秒时,显示消息“应用程序名称已停止”,如何更正?........................ .................................................. .................
我的组件
return (
<ReactNative.TextInput
ref={(ref: any) => { this.input = ref; }}
style={styleInputFormDefault}
numberOfLines={this.state.numberOfLines}
blurOnSubmit={true}
editable={this.state.editable}
underlineColorAndroid={"transparent"}
value={this.state.value}
multiline={this.state.multiline}
placeholder={this.state.placeholder}
keyboardType="default"
onChange={event => {
this.value = event.nativeEvent.text;
}}
onEndEditing={event => {
this.value = event.nativeEvent.text;
if (this.props.onChange != undefined) {
!this.props.onChange(this.value);
}
}}
returnKeyType={this.state.returnKeyType}
onSubmitEditing={() => {
if (this.props.onSubmit != undefined) {
this.props.onSubmit(this);
}
}}
onFocus={() => {
if (this.props.onFocus != undefined) {
this.props.onFocus();
};
}}
onBlur={() => {
if (this.props.onBlur != undefined) {
this.props.onBlur();
};
}}
>
</ReactNative.TextInput>
);
答案 0 :(得分:0)
尝试此修复程序-https://github.com/facebook/react-native/issues/17530
此修复程序已在的更高版本中提供。立即做出反应-https://github.com/facebook/react-native/pull/24183/commits/6310ad1e9441d532f930eb89e38300dbd973a919
答案 1 :(得分:-1)
为什么要像这样使用TextInput组件?只需从native native导入TextInput。
试试这段代码:
import React, { Component } from 'react'
import { TextInput } from 'react-native'
export default class InputClassName extends Component {
constructor(props) {
super(props)
this.input = null
this.state {
[...]
}
}
render() {
return(
<View>
<TextInput
ref={ref => this.input = ref}
style={styleInputFormDefault}
numberOfLines={this.state.numberOfLines}
blurOnSubmit={true}
underlineColorAndroid={"transparent"}
value={this.state.value}
multiline={this.state.multiline}
placeholder={this.state.placeholder}
keyboardType="default"
onChangeText={value => this.value = value}
onEndEditing={event => {
// I do not know what you're trying to do here
// Are you checking if the onChange props is a function? If so, do this instead:
// if("function" === typeof this.props.onChange) { [...] }
this.value = event.nativeEvent.text;
if (this.props.onChange != undefined) {
!this.props.onChange(this.value);
}
}}
returnKeyType={this.state.returnKeyType}
onSubmitEditing={() => {
// same goes here
if (this.props.onSubmit != undefined) {
this.props.onSubmit(this);
}
}}
onFocus={() => {
// also here
if (this.props.onFocus != undefined) {
this.props.onFocus();
};
}}
onBlur={() => {
// and here.
if (this.props.onBlur != undefined) {
this.props.onBlur();
};
}}
>
</TextInput>
{ /* Please note that you can also use propTypes in order to force (recommended)
a specific prop to be the typeof whatever you want instead of using if/else */ }
</View>
)
}
}