How to prevent form inputs from resetting?
Answered
Spectacled Caiman posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Spectacled CaimanOP
Sometimes after submit, the form inputs are cleared. I am using useFormState hook.
![Image](https://cdn.discordapp.com/attachments/1172812838478282883/1172812838767702117/Screenshot_2023-11-11_at_13.18.54.png?ex=6561ae12&is=654f3912&hm=d356e7cb40ba536abde3d1d3e151a173d9f388ebe81309a112e71e9adc61029e&)
Answered by Ray
then put it to default value of the input
<input type='text' name='email' defaultValue={state?.values?.email} />
7 Replies
![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
return the value from the server action then you can set the default value of the input from the form state
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Spectacled CaimanOP
Should I return formData from server action?
And use useState hook for form
![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
well, you can just return the errors with the previous value
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Spectacled CaimanOP
Okay thanks I will try
![Avatar](https://cdn.discordapp.com/avatars/743561772069421169/3c5d689eee4459a24fc420063411c016.webp?size=256)
Ray
then put it to default value of the input
<input type='text' name='email' defaultValue={state?.values?.email} />
Answer
![Avatar](https://cdn.discordapp.com/embed/avatars/5.png)
Spectacled CaimanOP
Thanks now working
![Image](https://cdn.discordapp.com/attachments/1172812838478282883/1172816485132013608/Screenshot_2023-11-11_at_13.33.26.png?ex=6561b177&is=654f3c77&hm=cb73063252f9831ffe25e6597e63db1f497bff01969379f3591eb007ba63fea5&)