---
title: "Why does my form reset after submitting in React 19?"
description: "React 19 clears uncontrolled fields after a form action finishes, even when it returns a validation error. Here is why, and how to keep what the user typed."
url: https://www.danny.engineering/answer/react/why-does-my-form-reset-after-submitting-in-react-19
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T17:23:00.000Z
tags: ["React"]
---

# Why does my form reset after submitting in React 19?

## The short answer


When you pass a function to a form's `action` prop, React 19 resets the form's uncontrolled fields once the action finishes. It does this even if your action returned an error message, so the user loses what they typed. Return the submitted values from the action and feed them back in as `defaultValue`, or handle the submission yourself with `onSubmit`.


```typescript
<input name="email" defaultValue={state.values.email} />
```


## Why it happens


Form actions are modelled on plain HTML forms. When a normal form submits, the browser loads a new page and the fields start empty. React copies that behaviour: after the action's transition completes, it resets the form, which puts every uncontrolled input back to its `defaultValue`.


React cannot tell whether a result counts as success in your app. An action that returns an object with an error message has still finished normally, so the reset still happens. Controlled inputs, where you pass `value` and keep the text in state, are not affected, because React renders them from your state again.


## How to fix it


### Return the submitted values and use them as defaultValue


This keeps the fields uncontrolled and works with Server Actions. The action returns what the user entered, and the reset restores each field to that value instead of an empty string.


```typescript
// app/subscribe/actions.ts
'use server';

export type FormState = {
  error?: string;
  values: { name: string; email: string };
};

export async function subscribe(
  prevState: FormState,
  formData: FormData
): Promise<FormState> {
  const values = {
    name: String(formData.get('name') ?? ''),
    email: String(formData.get('email') ?? ''),
  };

  if (!values.email.includes('@')) {
    return { error: 'Please enter a valid email address.', values };
  }

  await saveSubscriber(values);
  return { values: { name: '', email: '' } };
}
```


```typescript
// app/subscribe/subscribe-form.tsx
'use client';

import { useActionState } from 'react';
import { subscribe, type FormState } from './actions';

const initialState: FormState = { values: { name: '', email: '' } };

export function SubscribeForm() {
  const [state, formAction, isPending] = useActionState(subscribe, initialState);

  return (
    <form action={formAction}>
      <input name="name" defaultValue={state.values.name} />
      <input name="email" type="email" defaultValue={state.values.email} />
      {state.error && <p role="alert">{state.error}</p>}
      <button type="submit" disabled={isPending}>
        Subscribe
      </button>
    </form>
  );
}
```


On success the action returns empty values, so the form clears as expected.


### Handle the submission with onSubmit


The automatic reset only applies when a function is passed to `action`. If you call `preventDefault` in `onSubmit` and run the work yourself, React leaves the fields alone, and you decide when to clear them:


```typescript
'use client';

import { useTransition, type FormEvent } from 'react';
import { saveSubscriber } from './actions';

export function SubscribeForm() {
  const [isPending, startTransition] = useTransition();

  function handleSubmit(event: FormEvent<HTMLFormElement>) {
    event.preventDefault();
    const form = event.currentTarget;
    const formData = new FormData(form);

    startTransition(async () => {
      const result = await saveSubscriber(formData);
      if (result.ok) {
        form.reset();
      }
    });
  }

  return (
    <form onSubmit={handleSubmit}>
      <input name="email" type="email" />
      <button type="submit" disabled={isPending}>
        Subscribe
      </button>
    </form>
  );
}
```


You lose the progressive enhancement that form actions give you, because this form needs JavaScript to submit.


### Use controlled inputs for complex forms


If you already keep fields in state for live validation, pass `value` and `onChange`. The reset does not change controlled values.


## Common pitfalls

- Passing `value` without `onChange`. React makes the input read-only and warns in the console. Use `defaultValue` for uncontrolled fields.
- Forgetting selects and checkboxes. Use `defaultValue` on a `select` and `defaultChecked` on a checkbox in the same way.
- Sending sensitive fields back to the browser. Do not return passwords or card details in the state; let those fields clear.
- Expecting a new `defaultValue` to change a field the user is editing. It only takes effect on first render and when the form resets.
- Trying to refill a file input. Browsers do not allow it, so ask the user to choose the file again.

## Related reading

- [React: the form component](https://react.dev/reference/react-dom/components/form)
- [React: useActionState](https://react.dev/reference/react/useActionState)
- [React: requestFormReset](https://react.dev/reference/react-dom/requestFormReset)
