2017-06-14 5 views
-2

Wenn Eingabetext auf 3 Sekunden drücken, zeigen Sie die Nachricht "Anwendungsname ist gestoppt", wie Sie das korrigieren? ................ .................................................. ......................... enter image description hereEingang reagieren nativ - drücken Sie in Abstürze Anwendung

meine Komponente

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> 

    ); 

Antwort

0

Warum die Textinput-Komponente wie das verwenden? Importieren Sie einfach nur den TextInput von reaktionseigen.

Versuchen Sie diesen 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> 
    ) 
    } 
} 
Verwandte Themen