DEV Community

Alex Blinov
Alex Blinov

Posted on • Originally published at


Reset values in React Final Form

How to reset values in React Final Form after submitting

At first I wrote the following code:

  render={({ handleSubmit, form }) => (
      onSubmit={event => {
        handleSubmit(event).then(() => {

If we implement a function like this, we will get an error "Uncaught TypeError: Cannot read property 'then' of undefined”, when we try to submit invalid form.
Invalid forms β€” form with validation errors.

The solution

To avoid this error, we need to place handleSubmit(event) to a variable, and if the variable is not undefined call .then().

onSubmit={(event) => {
  const promise = handleSubmit(event);
  promise && promise.then(() => {
  return promise;

Top comments (0)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git