I know you can use resetForm in Formik to reset the form in onSubmit. However, is there a way to reset it programmatically by assigning it a ref and calling a rest form method on it somehow?
there is a prop called innerRef to make ref for a formik form
<Formik
innerRef={(p) => (this.formik = p)}
/>
then use it like this:
onPress={() => this.formik.resetForm()}
Or with a functional component:
const formikRef = useRef();
<Formik
innerRef={formikRef}
...
/>
and then use with
onPress={() => formikRef.current?.resetForm()}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With