Form (input, textarea)
State and hooks
const [changingValue, setChangingValue] = useState("initial value");
const handleChange = (event: FormEvent) => {
event.preventDefault();
// set the state here
setChangingValue();
};
const handleSubmit = (event: FormEvent) => {
event.preventDefault();
// some method to execute on submit
}
Textarea
<form onSubmit={handleSubmit}>
<textarea
className="border"
cols={40}
rows={15}
onChange={handleChange}
/>
</form>
Input
<form onSubmit={handleSubmit}>
<input type="" name="" placeholder="changingValue" onChange={(e) => handleChange(e.target.value)} />
<button>Submit</button>
</form>
Passing additional arguments to event
<input onChange={(event) => handleChange(event, "some argument")} />