jaredpalmer/formik

Use React.forwardRef in <Formik>

Open

#2208 aperta il 14 gen 2020

Vedi su GitHub
 (14 commenti) (4 reazioni) (0 assegnatari)TypeScript (2801 fork)batch import
Component: FormikFocus: TypeScripthelp wanted

Metriche repository

Star
 (34.255 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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?!?!

Guida contributor