-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TextInput OnChangeText is not called when the value is changed programmatically #19505
Comments
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
I have this issue too. I cant clear the text input programmatically. When I call textInputRef.clear() text input clears, but when after that I type something new in it the old text appears in front of the new text. |
this trick helped me this.setState({ searchText: '' }, () => { Keyboard.dismiss() }); |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions. |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information. |
react-native info
in your terminal and paste its contents under "Environment"share an app that reproduces the issue using https://snack.expo.io/
Environment
OS: Windows 10
Node: 6.11.5
Yarn: 1.3.2
npm: 4.6.1
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.0.0.0 AI-171.4443003
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4
Description
When a TextInput's value props is following a state/other prop's value, and when the state/other prop's value changed programmatically, the OnChangeText is not called.
However, editing the TextInput through keyboard will still trigger the OnChangeText.
Steps to Reproduce
react-native init newproject
App.js
filetext
state whose value is linked to a TextInput. After 3 seconds, thetext
state will be updated to a certain value, to check if the OnChangeText will be called.Expected Behavior
No matter which "source" of change to the TextInput's text, the OnChangeText event should be called.
Actual Behavior
The OnChangeText is only called when the TextInput is modified manually through keyboard input, but not programmatically.
I tested this issue in v0.53.3 as well and it has the same behavior.
This might not be a big issue ( at least for me, as my workaround is to call the
handleTextChanged
manually when I need it ), but if this issue can be fixed, it might help other people's businessThe text was updated successfully, but these errors were encountered: