📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials React Modern Development Event Handling

Event Handling

5 min read
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 (
    
); }