Closed 509dave16 closed 5 years ago
These are the best solutions that I could come up with. A text input mask that displays the transformed text. And an algorithm that takes the correct value from the out of sync native value provided by the TextInput: https://snack.expo.io/@509dave16/android-text-input-out-of-sync-solutions
@brentvatne Should I move all this information to issue #23578? Mine is kind of a duplicate. I was only able to find the other issue after writing up this very exhaustive issue. So I figure if asked, I could migrate all of this information to the other issue.
@509dave16 - yeah, that could be useful to add your report as a comment on the existing issue and close this one
@brentvatne Awesome. Thank you for your reply! Closing issue. This report has been added here to this already existing issue: https://github.com/facebook/react-native/issues/23578#issuecomment-521821027
@509dave16 This problem was happening with my react-native App too. What I did is that I created an individual components out side the main component( where we will place this component) keeping TextInput as a whole(i.e according to our requirement that means what field do we need) in one single component. Passing the value as props to this component and changing it whenever we require using onChangeText. The idea is that we need to change only this particular component not the whole screen. The problem was solved in my App.
Summary
When attempting to ignore certain characters by controlling the state value that's passed to the TextInput, the TextInput's natively held value get's out of sync. This makes it impossible to enforce a particular text pattern at the time of a user entering the text. This exact issue was occurring before React Native 57.1 on iOS, as noted here in this now closed issue #18874 . There is also this existing issue #23578 that covers this bug that still exists on Android. If you would like I can move parts of my issues content over there as comments.
React Native version: 0.59.8(based on Expo SDK 34)
Steps To Reproduce
onChangeText
event handler that will selectively choose to not update the state value(which control's the TextInput's natively stored value). For example, let's say uppercase letters like 'A', 'B', 'C', etc...Describe what you expected to happen:
Snack, code example, screenshot, or link to a repository