Search code examples
androidreact-nativestatereact-native-textinput

TextInput value is not updated after changing state?


        <TextInput
            label={'Please enter your email'}
            onChangeText={text => this.onChangeText(text)}
            style={textInputStyle}
            value={this.state.testEmail}
        />

Check the function which I'm using to handle the text, where I'm appending some dummy text but it's not getting reflected.

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

Here's the constructor,

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

Solution

  • shouldComponentUpdate This method was calling anonymously which was resulting not to update the TextInput