The recommended usage of formik in react native is: <Button onPress={props.handleSubmit} />. However, when using typescript, the type of event that handleSubmit accepts is different than what react-native's onPress generates.
Formik's handleSubmit should take a GestureResponderEvent in addition to React.FormEvent<HTMLFormElement>.
This branch fixes this issue: https://github.com/Shurelia/formik/tree/handleSubmit-fix
Unfortunately, there is a typings conflict between @types/node and @types/react-native which prevents the build. Since the only type used from node was process, I've manually declared that as any and removed @types/node. Not an elegant solution, and I'd be open to working on it more if the maintainers are okay with removing @types/node from the project (and perhaps manually declaring process?).
Yeah this is legit. Hmmmmm. I think it may be time for Formik-native. In the mean time you can call submitForm()
I got stuck there too when trying to support React Native and TypeScript. I鈥檓 cool with dropping types/node if this works.
Thanks for the tip on submitForm()! I put in a PR anyways (#379), as it seemed an easier fix than writing new documentation to explain why submitForm should be called instead.
As a side note, I'm really digging this library. Thanks for all the hard work! This has solved a lot of the issues I was having with redux-form, and the ease of integration with react native has made it a joy to work with.
I see #379 was backed out (Re: #421). What is the current solution?
For all coming here: The issue seems to be still open.
If you simply want to remove the warning you can cast your object. It's by far not the cleanest solution, but it's better than nothing.
onPress={handleSubmit as any}
@jaredpalmer Any valid solution for correct typing in react-native?
TypeScript is supported and React Native is supported but both at the same time aren't? 馃
Most helpful comment
For all coming here: The issue seems to be still open.
If you simply want to remove the warning you can cast your object. It's by far not the cleanest solution, but it's better than nothing.
onPress={handleSubmit as any}