-
Notifications
You must be signed in to change notification settings - Fork 24k
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
maxLength
of TextInput does not work when value is changed after state update
#44965
Comments
I was debugging this and found that this method is getting called whenever text is updated from react's state change. This method then calls When input is received from keyboard this method is called which has Any reason for not checking |
@sammy-SC could you please take a look into this? Thank you for your time. |
The code you are linking is for the new architecture but your repro is with the old architecture. This can be annoying but there is a simple workaround if this is blocking you. When setting text from React, you can check for the length of new text value and shorten it if it goes over the maxLength. |
Thank you for the clarification and sorry for wrong linking of code. I pushed repro for new architecture here. Thank you for suggesting workaround. I have checked that the |
@sammy-SC if you agree that iOS should handle |
Description
maxLength
of Text Input is not working when value is changed after state update. It works as expected when input is given with keyboard.<TextInput style={styles.textInput} value={description} maxLength={10} onChangeText={text => setDescription(text)} />
Steps to reproduce
maxLength
of TextInput to any non zero numbermaxLength
maxLength
React Native Version
0.74.2
Affected Platforms
Runtime - iOS
Output of
npx react-native info
Stacktrace or Logs
Reproducer
https://github.com/kunalchavhan/rn-textinput-maxlength-reproducer
Screenshots and Videos
maxlength-reproducer-1.mov
The text was updated successfully, but these errors were encountered: