Handle events with camelCase props: onClick, onChange, onSubmit. Pass a function reference or an inline arrow function. Call e.preventDefault() to stop form submission and e.target.value to read input text.
Event Handling in React
function Form() {
const [value, setValue] = useState("");
function handleChange(e) {
setValue(e.target.value);
}
function handleSubmit(e) {
e.preventDefault();
console.log("Submitted:", value);
}
return (
);
}