Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 文本输入值在更改状态后未更新?_Android_React Native_State_React Native Textinput - Fatal编程技术网

Android 文本输入值在更改状态后未更新?

Android 文本输入值在更改状态后未更新?,android,react-native,state,react-native-textinput,Android,React Native,State,React Native Textinput,这是构造器 onChangeText = (text, id) => { this.setState((previousState) => ({ testEmail: text+'test' } ) ) } 试试这个: constructor(props) { super(props); this.state = { testEma

这是构造器

onChangeText = (text, id) => {
    this.setState((previousState) => ({
                testEmail:
                text+'test'
            }
        )
    )
}
试试这个:

constructor(props) {
    super(props);
    this.state = {
        testEmail: '',
    };
}

onChangeText=text=>{
这是我的国家({
testEmail:`${text}测试`
});
}

小吃样本。

shouldComponentUpdate
此方法匿名调用,导致无法更新
TextInput

我尝试了您的expo项目,效果很好。但是我复制了完全相同的代码,它在我的项目中不起作用。问题是文本被替换回空字符串。
constructor(props) {
    super(props);
    this.state = {
        testEmail: '',
    };
}
<TextInput
  label={'Please enter your email'}
  onChangeText={this.onChangeText}
  style={textInputStyle}
  value={this.state.testEmail}
/>

onChangeText = text => {
  this.setState({
    testEmail: `${text}test`
  });
}