Closed tuppers360 closed 5 months ago
This is a known issue. There will be a new useAction
hook that unifies useFormState
and useFormStatus
.
Super thanks for replying! I was going a little stir crazy trying to figure that out!
Using your youtube video with onSubmit={() => { form.handleSubmit(() => formRef?.current?.submit()); }}
instead seems to work but not sure it isn't causing any issues elsewhere
You should check the most recent code on that, some folks found issues with submitting after a navigation and this was the fix:
onSubmit={(evt) => {
evt.preventDefault();
form.handleSubmit(() => {
formAction(new FormData(formRef.current!));
})(evt);
}}
I tried using most recent code. This causes form not to reset. Following code works well for resetting.
onSubmit={(evt) => {
evt.preventDefault();
form.handleSubmit(() => {
formRef.current?.submit();
})(evt);
}}
Sorry, but not sure what bug following code is fixing. Would you be able to help. So I don't miss issues.
formAction(new FormData(formRef.current!));
Hi
Firstly thanks do much for this code and the videos that come with it, it has really helped a lot.
I am struggling to pass
const { isSubmitting } = form.formState;
to a button component or useconst { pending } = useFormStatus();
to display a spinner when submitting a form.I believe its due to how the form is submitted using:
ref={formRef} action={formAction} onSubmit={(evt) => { form.handleSubmit(() => { formAction(new FormData(formRef.current!)); })(evt); }}
Is there something I am missing here?
Thanks