Sep 2, 2018 · 1 min read
Hey Jozef Mikura!
You’d have to modify the form a little (I am actually going to update tutorial to do that too). You have to wrap the form in <form> tags and then add onSubmit event handler that takes e (event argument) and then does e.target.reset(); to clear the fields.
const NewFruit = (props) => {
let formFields = {}
return(
<form onSubmit={(e) => { props.handleFormSubmit(formFields.name.value, formFields.description.value); e.target.reset()}}>
<input ref={input => formFields.name = input} placeholder='Enter the name of the item'/>
<input ref={input => formFields.description = input} placeholder='Enter a description' />
<button>Submit</button>
</form>
)
}