October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

React Controlled vs. Uncontrolled Components: What’s the Difference?

Controlled React fields get their current value from state; uncontrolled fields keep it in the DOM. Learn which pattern to use and how native form props work.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In React, a controlled component gets an important value from props, while an uncontrolled component keeps that value in its own state. For native form fields, the practical distinction is whether you provide value or checked for the current value, or use defaultValue or defaultChecked only to set the starting value.

Use controlled state when React needs to respond to each edit or coordinate the value across the interface. Use an uncontrolled field when the value can stay in the DOM until you need it, such as when submitting a form. These labels are useful design shorthand, not rigid categories: a component can combine parent-driven props and local state.

What is the difference between controlled and uncontrolled components in React?

The distinction is about where important state lives and who can change it. React describes a component as controlled when important information is driven by props, and uncontrolled when it keeps that information in its own local state. A parent can specify a controlled child’s behavior; an uncontrolled child needs less configuration from its parent but is harder to coordinate with other components. See React’s guide to sharing state between components.

Question Controlled Uncontrolled
Where is the current value? In React state, typically owned by a parent and passed to the field as a prop. In the field’s current DOM value.
How much coordination is possible? React can use each edit to update other components or interface elements. The parent does not need to configure every edit, but other UI cannot automatically coordinate from React state.
What must be configured? A current value and an event handler that updates it. Usually less configuration; an initial value can be supplied if needed.
How is the value read on submit? Read the value from React state. Read a named field from the form using FormData.
What constraints apply? Update the backing state synchronously and keep the value’s type stable. Do not later switch the field to controlled mode.

These general component-design terms should not be confused with React’s specific rules for native <input>, <select>, and <textarea> elements. Those fields have explicit controlled and initial-value props.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What’s the difference between value and defaultValue?

For a text input, value sets the current value from React. The field is controlled, so it needs an onChange handler that synchronously updates the backing value. defaultValue sets only the initial text; after that, the field’s current value is held by the DOM. React documents these rules in its <input> reference.

const [name, setName] = useState('');

<input value={name} onChange={event => setName(event.target.value)} />

Here, the handler immediately updates state to match the edit. If a controlled field rerenders with its previous value because the handler did not update the state synchronously, the typed character can appear to revert.

<input name="name" defaultValue="Taylor" />

This field starts with “Taylor,” but its current value is not controlled by React state. The name makes it available when reading form data.

Checkboxes and radio buttons use checked props

For a controlled checkbox or radio, use checked for its current selection and update it synchronously in onChange. Use defaultChecked to specify only the initial selection. value is not a substitute for checked state; it represents a different aspect of the form control.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Select menus and textareas

For a <select>, value controls the current selection and defaultValue sets the initial selection. For a multiple-select menu, either prop can take an array of strings. Set selection on the parent <select>, not with a selected prop on an individual <option>. A <textarea> follows the same controlled-versus-initial pattern: value controls its text, while defaultValue supplies initial text. Controlled textareas also need a synchronous update handler. Consult React’s references for <select> and <textarea>.

Keep a field in one mode

A native field must not switch between controlled and uncontrolled during its lifetime. For example, avoid rendering value={undefined} and supplying a string later. Initialize controlled text state to '', or normalize nullable data so the prop remains a string. A controlled checkbox should receive a boolean value for checked.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When should I use controlled or uncontrolled components?

Choose controlled state when the interface must react to edits

Make a value controlled when other parts of the interface need to respond as the user types, when more than one action can change it, or when multiple components must stay synchronized. For example, controlled state is useful for showing live validation or a preview, mirroring text in another field, or changing a field from a button. The parent passes the current value and an update handler to the child.

Choose uncontrolled state when the value is only needed later

An uncontrolled field fits when the parent does not need each edit and can read the value when the user submits the form. React’s form guidance shows reading named fields with new FormData(form). For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
function handleSubmit(event) {
  event.preventDefault();
  const formData = new FormData(event.currentTarget);
  const name = formData.get('name');
}

<form onSubmit={handleSubmit}>
  <input name="name" defaultValue="Taylor" />
  <button type="submit">Save</button>
</form>

With a controlled field, use the state variable instead of reading its current value from FormData. React also documents that function form actions reset uncontrolled fields; see the <form> reference.

How do I keep two React inputs in sync?

Put the shared value in the closest common parent of the inputs, then pass that value and update handlers down to both. This is called lifting state up: the parent becomes the single source of truth for that piece of information.

function Parent() {
  const [text, setText] = useState('');

  return (
    <>
      <input value={text} onChange={event => setText(event.target.value)} />
      <input value={text} onChange={event => setText(event.target.value)} />
    </>
  );
}

Both fields receive the same current value, and either field’s handler updates it. Avoid keeping separate copies of the shared value in the two children: those copies can diverge.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.