2

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 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.