Put in order · JavaScript and React course · Module 3: State and Events

Controlled Input Cycle

Arrange what happens after typing one character into the controlled field <input value={name} onChange={(e) => setName(e.target.value)} />:

Items to put in order

  • The handler calls setName(e.target.value)
  • The user types a character into the field
  • The component re-renders with the new name
  • The field shows the new value because value={name}
  • React calls onChange with the event object

You can check the correct answer by solving this task in the CodeWorlds game.