-
Notifications
You must be signed in to change notification settings - Fork 452
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 ref methods are broken #44
Comments
Hi Partric, this obviously is a bug/missing functionality. We're putting it in our roadmap for one of the next releases. |
Is there any temporary solution? |
Yes, if you copy the TextInput from this library (https://github.com/shoutem/ui/blob/develop/components/TextInput.js), add a ref at line 22, like so: <RNTextInput
{...props}
style={style}
placeholderTextColor={props.style.placeholderTextColor}
selectionColor={props.style.selectionColor}
ref={(input) => this.props.inputRef(input)}
/> Then, using that textinput, you can use the <TextInput inputRef={(input) => { this.textInput = input }} /> The input ref is now available via |
I'm trying out the temporary solution above, and I can't get it to work. I get the following error message: |
Okay, I found out that by making my own copy of TextInput , and adding a |
It sounds like you used a string based ref, its recommended to use a callback ref instead. |
Hi, any progress on this bug? |
For anyone ending up here struggling with focussing the next TextInput: |
This issue is still there. Kindly help us. Because this function is very basic. |
Workaround is to use
|
fixed in #471 |
can you help me by showing what you did in your code? |
This solution resolve if I own two input component, but where try move to the next input (the third input in screen) , does not work |
Check out this solution: https://stackoverflow.com/a/77693296/15526921 If you've wrapped a React Native TextInput within a new component and you find that the ref is not working as expected to move to the next input when submitted, there are a few potential reasons and solutions you can explore:
Ensure that you are correctly passing the ref from the parent component to the wrapped TextInput component. If you are using functional components, you can use the useImperativeHandle hook to expose specific methods or properties of the child component.
Ensure that you are using the forwardRef function when creating your custom component. This is necessary to forward the ref from the parent component to the child component.
If the ref is properly passed, ensure that you are using the focus() method on the next TextInput component in the parent component's handleSubmit function.
Generated by ChatGPT 3.5 and worked for me after trying several solutions |
I try to call the focus() method on a TextInput ref. Such as
However I get the following Error Message:
_this.refs[nextField].focus is not a function
The Reference Type seems to be different compared to the React Native core and doesn't offer methods such as
focus()
The text was updated successfully, but these errors were encountered: