Controlled Inputs in React

From the React Components & JSX cheat sheet · Forms & Controlled Components · verified Jul 2026

Controlled Inputs

Form inputs controlled by React state

javascript
function Form() {
  const [name, setName] = React.useState('')
  
  return (
    <div>
      <input 
        type="text"
        value={name}
        onChange={(e) => setName(e.target.value)}
        placeholder="Enter name"
      />
      <p>Hello, {name}!</p>
    </div>
  )
}
🟢 Essential - React controls the input value
💡 Value comes from state, onChange updates state
📌 Single source of truth for form data
formscontrolledessential

More React tasks

Back to the full React Components & JSX cheat sheet