[TextInput] [android] setNativeProps({text:<string>}) repeats characters
See original GitHub issue🐛 Bug Report
Setting the text of a TextInput on Android via setNativeProps({text:<string>})
repeats existing characters
iOS | Android |
---|---|
![]() |
![]() |
To Reproduce
Add a TextInput in Android and capture a ref to it. Add an onChangeText
handler to the TextInput, and in this, set the text of the input to some function of the current text.
As characters are typed into the input, the text will repeat previously input characters in addition to the value of the string used in setNativeProps.
Expected Behavior
Setting the text via setNativeProps({text:<string>})
should set the text of the input to just <string>
with no repeated characters.
Code Example
On latest react native, via react-native init
import React, {Component} from 'react';
import {Text, View, TextInput} from 'react-native';
type Props = {};
export default class App extends Component<Props> {
render() {
return (
<View style={{paddingTop:200}}>
<TextInput style={{width:"100%",backgroundColor:"yellow"}}
ref={(r)=>this.textInputRef=r} onChangeText={(t)=>this.textInputRef.setNativeProps({text:t.toUpperCase()})}>
</TextInput>
</View>);
}
}
Link to snack: https://snack.expo.io/Hk-z-q3FV
Environment
React Native Environment Info: System: OS: macOS 10.14.4 CPU: (8) x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz Memory: 216.29 MB / 16.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 8.15.1 - ~/.nvm/versions/node/v8.15.1/bin/node Yarn: 1.12.3 - ~/.yarn/bin/yarn npm: 6.4.1 - ~/.nvm/versions/node/v8.15.1/bin/npm Watchman: 4.7.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2 Android SDK: API Levels: 25, 26, 27, 28 Build Tools: 25.0.3, 28.0.3, 29.0.0 System Images: android-28 | Google APIs Intel x86 Atom IDEs: Android Studio: 2.3 AI-162.3871768 Xcode: 10.2/10E125 - /usr/bin/xcodebuild npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.4 => 0.59.4
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:21 (5 by maintainers)
This issue is still happening in
react-native 0.59.10
I’m encountering this issue on Android on react-native 0.64.3.