When press input text to 3 seconds, show the message "Application name is stopped", how to correct this?...........................................................................................
my component
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>
);
Try this fix - https://github.com/facebook/react-native/issues/17530
This fix is already available in a higher version of. react-native now - https://github.com/facebook/react-native/pull/24183/commits/6310ad1e9441d532f930eb89e38300dbd973a919
Why are using the TextInput component like that? Simply import just the TextInput from react native.
Try this code:
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>
)
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.