I'm using withFormik HOC to manage my form with Formik. The form component has useState hooks to show messages. How do I call this hook from handleSubmit handler? I also tried to return Promise from handleSubmit but that doesn't seem to work.
1 Answer
I think there are two possible ways to achieve this, one is to use Formik component instead of HOC and then do whatever you want in onSubmit callback, and second is to create your custom event handler and call submitForm function like:
function onSubmit() { // Do something formik.submitForm() } In my opinion first approach is more cleaner and you’ve more control.