const [form, setForm] = useState({
name: "", price: "", rating: "", weight: ""
})
const onChangeHandler = event => {
setForm({...form, [event.target.name] : event.target.value})
}
export default function FuncName(){
const [form, setForm] = useState({
name: "", price: "", rating: "", weight: ""
})
onSubmitHandler() {
setForm({
name: "", price: "", rating: "", weight: ""
})
}
render() {
return (
<form onSubmit={onSubmitHandler}>
<...>
</form>
);
}
}
}