Course contentsShow
← React
Lesson 503 of 2,39614. Uncontrolled ComponentsFree lesson

When Default Props Don't Update

Understand that changing defaultValue/defaultChecked props after mount has no effect—they're initialization only.

When Default Props Don't Update

What you'll learn: Why changing defaultValue or defaultChecked after a component mounts has no effect on uncontrolled inputs.

The Initialization-Only Nature of Default Props

When you use defaultValue or defaultChecked on an uncontrolled input, React reads these props only once—during the component's initial mount. After that, the DOM element takes over and React no longer syncs these props to the input's actual value.

Think of it like setting the factory settings on a device. Once the device is powered on and the user starts interacting with it, sending new "factory settings" commands does nothing—the device is already running with its own state.

function BrokenExample() {
  const [initialValue, setInitialValue] = useState('Hello');

  return (
    <div>
      <input defaultValue={initialValue} />
      <button onClick={() => setInitialValue('Goodbye')}>
        Change Default
      </button>
    </div>
  );
}

Clicking the button won't update the input. The input displayed "Hello" on first render, and now the DOM owns that value. React isn't watching or controlling it anymore.

Why This Happens

defaultValue is specifically designed to set the initial value while leaving the input uncontrolled. After mount, the input's actual value lives in the DOM, not in React state. Changing the prop doesn't tell the DOM to update—React only used it once during creation.

The Solution

If you need to update an input's value programmatically, you must either:

  1. Use a controlled component (value + onChange)
  2. Use a ref to imperatively set inputRef.current.value
  3. Force remount by changing the component's key (rare, usually overkill)

Key Takeaway: defaultValue and defaultChecked are initialization-only props—changing them after mount has no effect because uncontrolled inputs are managed by the DOM, not React state.