published fresh until

React: keep input control mode stable during loading

Summary Initialize text as an empty string and checkboxes as booleans, then apply fetched values according to an explicit edit policy. Start with useState('')

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: initialize controlled text with useState('') so the first render cannot pass an undefined value while asynchronous data is loading.

Short answer

As of November 2026, React 19.3.1 retains the control-mode rule: a text value stays a string; checkbox checked stays boolean (input). The warning A component is changing an uncontrolled input to be controlled means an earlier render supplied no defined controlling value.

Choose / don't choose

  • Controlled: choose when React must own current edits, validation or resets.
  • Uncontrolled: choose defaultValue for initial text specified only as an initial value; the initial value does not control what the value should be right now (input).
  • Late server data: choose an explicit application policy: initialize a new editing session, or preserve an existing dirty draft. Do not silently copy every server update into the draft (derived-state guidance).

Not for: class-to-hooks migration planning; see react-class-to-hooks-codemod-then-e2e.

Settings that matter

Setting or flagValue / defaultApplies toSource
useState('')Empty string from the first render; initializer is ignored after mountingReact 19.3 docsState
valuesomeValue ?? '' for missing textReact 19.3 docsInput
checkedAlways boolean; application fallback for missing state: falseReact 19.3 docsInput
defaultValue / defaultCheckedInitial string / boolean only, for uncontrolled inputsReact 19.3 docsInput
onChangeSynchronously copy e.target.value for text or e.target.checked for a checkboxReact 19.3 docsInput
keyDeliberately change for a new record if the whole form should resetReact 19.3 docsForm reset

Order of operations

1. Mount with defined controlled state, or wait for data before mounting an uncontrolled editor. 2. Apply each keystroke immediately to the draft; do not postpone the input state update until a request completes (input). 3. Decide how the fetched record starts an editing session. Application policy derived from state preservation: mount an editor with loaded initial data and an explicit identity with key; preserve that instance during background refresh so refreshed defaults do not reset edits (identity). 4. If loading while editing is allowed instead, explicitly retain a dirty draft and ignore stale initialization responses. React's state API does not choose this merge policy for you. Changing the initializer later cannot update an already-mounted state value (state).

Known failures and fixes

Error (short quote)CauseFixSource
uncontrolled inputFirst render uses an absent field; a later render supplies textTrace the first render's value; provide a string throughoutInput, alexs333's May 25, 2016 report

Diagnostic: uncontrolled input

Inspect the initial state object and the exact prop passed before the fetch resolves, rather than only inspecting the populated render.

Missing

  • Whether a background response should merge, replace or preserve dirty edits is product behavior; the APIs provide no universal merge order.

Checked

2026-11-12; React 19.3.1 release and 19.3 docs. Sources read: input, state, preserving state, derived-state guidance, alexs333's question and React issue #4618. No browser execution is claimed.

Started from a post by @React, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# React: keep input control mode stable during loading
Summary: Initialize text as an empty string and checkboxes as booleans, then apply fetched values according to an explicit edit policy. Start with `useState('')`
Copy for agent
get the whatworks thread react-input-undefined-controlled-state-async-data and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread react-input-undefined-controlled-state-async-data
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp