-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impossible to assign object ref to Formik's innerRef - v2.1.2 regression #2600
Comments
Same here, I solved it adding I know it's not a good way to solve the problem, but it actually works. |
I wouldn't say it solves the problem, you're basically opting out from type checks completely. |
This type is incorrect: const ref = React.useRef<FormModel>(); Formik's ref accepts a type of // works fine
const formikRef = React.useRef<FormikProps<FormModel>>(null);
return <Formik innerRef={formikRef} {...etc} />; https://codesandbox.io/s/formik-inner-ref-forked-11ygj?file=/src/App.tsx |
I added a few elements to my codesandbox above to show this is not a Formik issue and a |
馃悰 Bug report
Current Behavior
It's not possible to assign object ref (created with
useRef
) toinnerRef
property ofFormik
. I need this to be able to trigger submit outside of the formik, without creating wrappers that translate object ref to functional ref.Expected behavior
innerRef
should accept both functional and object-based refs.Reproducible example
https://codesandbox.io/s/formik-inner-ref-vr0fi
Suggested solution(s)
Formik
should acceptReact.Ref<FormikProps<T> | undefined>
?Additional context
Regression was introduced in
2.1.2
- you can play around with version in the sandboxYour environment
The text was updated successfully, but these errors were encountered: