Skip to content

Uncontrolled Component

In one line

An uncontrolled component is a form input where the DOM holds the value, and React reads it via a ref — typically on submit.

In simple words

An uncontrolled input lets the DOM manage the value. You don't bind value to state — instead, you use a ref to read the value when you need it (usually on form submit). You can set a default with the defaultValue prop.

const inputRef = useRef() ... <input ref={inputRef} /> ... inputRef.current.value gives you the text. This is closer to traditional HTML form behavior.

Uncontrolled inputs are simpler for forms where you only need the value on submit and don't need real-time validation or transformation. But they are less React-idiomatic and harder to integrate with validation libraries. Most React forms use controlled components.

Example

jsx
function NameForm() {
  const inputRef = useRef(null);

  const handleSubmit = (e) => {
    e.preventDefault();
    console.log(inputRef.current.value); // read on submit
  };

  return (
    <form onSubmit={handleSubmit}>
      <input ref={inputRef} defaultValue="Alice" />
      <button type="submit">Submit</button>
    </form>
  );
}

The input's value lives in the DOM. The ref gives access to it on submit. defaultValue sets the initial text without controlling it.

Related terms

Related Resources

Related Lessons

  • Forms

    Learn uncontrolled inputs and when to use them.

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary