Skip to content

TextInput OnChangeText event fires before OnKeyPress #26290

Closed
@srilalitharanikintali

Description

@srilalitharanikintali

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

  1. clone the repository
  2. run the app
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugComponent: TextInputRelated to the TextInput component.Platform: LinuxBuilding on Linux.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions