Created
November 25, 2024 07:51
-
-
Save ellemedit/5c3bf2eedc3babc46151d5526e554768 to your computer and use it in GitHub Desktop.
Form submit without resetting in React 19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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