this is the form component that was not resettin or custom changing after submitting the form
[this is the item list component (https://i.stack.imgur.com/nIuLB.png) ][this is form output after submitting a item (https://i.stack.imgur.com/OChL5.png)]
I really dont seem understand why setformdata works for onchange event but not for the onsubmit event
3
Answers
useState is asynchronous. A workaround to get the effect you want is by using
useEffect
hook and adding the variable to the dependency arrayYou should set value of input that named "product" :
And
In the input field u need to set the value of formData