DEV Community

Discussion on: Using Forms In React.js, The Right Way (no library needed)

Collapse
 
jai_type profile image
Jai Sandhu

Interesting approach, how do you clear the form when it’s submitted?

Collapse
 
itays123 profile image
Itay Schechner

If you need to clear the form on submit, set the value of the fields in the submit handler of your context. Then create a form warpper with the on Submit event, or attach it to the onClick event of the submit button and the onKeyEnter event of the last input field.