-
Notifications
You must be signed in to change notification settings - Fork 50
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
Using React Hooks & withNextInputAutoFocus together #109
Comments
Have you tried using https://reactjs.org/docs/hooks-reference.html#useimperativehandle |
I tried using useImperativeHandle with forwardRef and this module, but cannot get it to work. What it tries to do is submit the entire form instead of just focusing to the next input. What am I missing?
I'm creating my input in the parent form with:
|
@appjitsu You need to move the const ComposedTextInput = compose(
handleTextInput,
withInputTypeProps,
withNextInputAutoFocusInput, // <- here
)(TextInput); |
This solution worked for me: import React, { forwardRef } from 'react'
import { TextInput } from 'react-native'
import {
handleTextInput,
withInputTypeProps,
withNextInputAutoFocusInput,
} from 'react-native-formik'
import { compose } from 'recompose'
const CustomTextInput = (props, ref) => {
return (
<TextInput {...props} ref={ref}/>
)
}
export const FormikInput = compose(
handleTextInput,
withInputTypeProps,
withNextInputAutoFocusInput,
)(forwardRef(CustomTextInput)) |
Thanks for this awesome lib, it has been fun all the time to use it. I have a question though on how could i use withNextInputAutoFocus and my functional Hooks component. According to your docs, using withNextInputAutoFocus requires us to have a focus method, with a sole purpose to focus on the element.
The problem occurs when I'am using hooks. As we know that in functional component you can't have a method, on the other hand, because you want to use hooks you cannot use class. So I'am stuck in the middle of both. I really hope I can use Hooks and withNextInputAutoFocus together as I really enjoyed working with both.
The text was updated successfully, but these errors were encountered: