'what is the easiest way to refresh the form in react without 'using react hook form' right after submission?
I created a form with html5 in react app but did not find any simple way to clear all input field with clicking the submit button. So I wrote a function and write the codes with basic java script inside it and call it in the function which is connected to the submit button.
It worked fine but I want to know is there any other way to clear them all with one click not writing document.getElementById("sample-id")
for each input field. Please don't suggest me react hook form
const refreshForm = () =>{
document.getElementById('name').value='';
document.getElementById('price').value='';
document.getElementById('supplier').value='';
document.getElementById('quantity').value='';
document.getElementById('description').value='';
document.getElementById('image').value='';
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|