How to prevent form inputs from resetting?
Answered
Spectacled Caiman posted this in #help-forum
Spectacled CaimanOP
Sometimes after submit, the form inputs are cleared. I am using useFormState hook.
Answered by Ray
then put it to default value of the input
<input type='text' name='email' defaultValue={state?.values?.email} />
7 Replies
return the value from the server action then you can set the default value of the input from the form state
Spectacled CaimanOP
Should I return formData from server action?
And use useState hook for form
well, you can just return the errors with the previous value
Spectacled CaimanOP
Okay thanks I will try
then put it to default value of the input
<input type='text' name='email' defaultValue={state?.values?.email} />
Answer
Spectacled CaimanOP
Thanks now working