-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Description
On version 0.54.2 on iOS
When typing in a TextInput with a controlled value prop, multiple onSelectionChange events fires.
You don't always see the flickering when rendering, but this can cause problems if you have a very long TextInput or use the selection prop in other ways.
Environment
Environment:
OS: macOS High Sierra 10.13.3
Node: 9.8.0
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: ^16.3.0-alpha.1 => 16.3.0-alpha.1
react-native: 0.54.2 => 0.54.2
Expected Behavior
One onSelectionChange event is fired and cursor doesn't jump to end and back.
Actual Behavior
For every keystroke there is one instant correct event, then the new value goes through setState and renders down into the value prop again. This causes two more events: one where selection is at end of the string, followed by one correct event.
Steps to Reproduce
The code I used to test is in this snack: https://snack.expo.io/HJaZucVYf
Use that code with v0.54.2 to reproduce
