Search code examples
react-nativereact-native-textinput

The TextInput onChange is one step behind


Kindly refer to the codesandbox link for code.

Basically the input is lagging by one key press although I explicitly added the compute function in the callback of setState.

Edit: I understand the solution but I want to know why this is happening since I calling the function in the callback of setState.


Solution

  • You can use

    onChangeText method which gives value directly.

    <TextInput onChangeText = {(value)=>{console.log(value)}} />