Skip to content

Instantly share code, notes, and snippets.

@ellemedit
Created November 25, 2024 07:51
Show Gist options
  • Save ellemedit/5c3bf2eedc3babc46151d5526e554768 to your computer and use it in GitHub Desktop.
Save ellemedit/5c3bf2eedc3babc46151d5526e554768 to your computer and use it in GitHub Desktop.
Form submit without resetting in React 19
export function Form() {
const [isPending, startTransition] = useTransition()
return (
<form
onSubmit={(event) => {
event.preventDefault()
const formData = new FormData(event.currentTarget)
startTransition(async () => {
await someAction(formData)
})
}}
>
...
</form>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment