jaredpalmer/formik

Use React.forwardRef in <Formik>

Open

#2 208 ouverte le 14 janv. 2020

Voir sur GitHub
 (14 commentaires) (4 réactions) (0 assignés)TypeScript (34 255 stars) (2 801 forks)batch import
Component: FormikFocus: TypeScripthelp wanted

Description

As of 2.1.2, <Formik> now allows for an innerRef prop. However, we should instead use React.forwardRef + React.useImperativeHandle. This is more intuitive and closer to best practices. The problem though, is that <Formik> takes TypeScript generics for Values and I'm not sure how to express this in with forwardRef. AFAICT, you can't because forwardRef returns a constant and constants can't have generics.

Help?!?!

Guide contributeur