Description
When using onKeyPress
event and onChangeText
event in TextInput
I have a use case where I am updating the state value in onChangeText
but I need the previous state value for my onKeyPress
event but it happens to be that onChangeText
is first updating the state value and then onKeyPress
is receiving the updated value
Documentation Link: https://facebook.github.io/react-native/docs/textinput#onkeypress
React Native version:
System:
OS: Linux 4.15 Ubuntu 18.04 LTS (Bionic Beaver)
CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
Memory: 237.38 MB / 15.53 GB
Shell: 4.4.19 - /bin/bash
Binaries:
Node: 10.16.1 - ~/.nvm/versions/node/v10.16.1/bin/node
Yarn: 1.17.3 - /usr/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.1/bin/npm
SDKs:
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.0
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.60.4 => 0.60.4
npmGlobalPackages:
react-native-cli: 2.0.1
Steps To Reproduce
- clone the repository
- run the app
- use the remote debugger and check in the console
Given Input: abc
onKeyPress
is fired with backspace there the expected state value is abc
Repository link: https://github.com/srilalitharanikintali/onKeyPressIssue