What are controlled components and uncontrolled components in ReactJS? How do they differ from each other?
9 Answers
This relates to stateful DOM components (form elements) and the React docs explain the difference:
- A Controlled Component is one that takes its current value through
props
and notifies changes through callbacks likeonChange
. A parent component "controls" it by handling the callback and managing its own state and passing the new values as props to the controlled component. You could also call this a "dumb component". - A Uncontrolled Component is one that stores its own state internally, and you query the DOM using a
ref
to find its current value when you need it. This is a bit more like traditional HTML.
Most native React form components support both controlled and uncontrolled usage:
// Controlled:
<input type="text" value={value} onChange={handleChange} />
// Uncontrolled:
<input type="text" defaultValue="foo" ref={inputRef} />
// Use `inputRef.current.value` to read the current value of <input>
In most (or all) cases you should use controlled components.

- 49,769
- 26
- 85
- 103
-
4Isn't the value taken through `state` rather than `props`? – Ivanka Todorova Oct 04 '18 at 20:27
-
26@IvankaTodorova For a controlled component the value is passed in through `props`. An uncontrolled component would use `state` to control the value itself internally. This is the key difference. – Aaron Beall Oct 04 '18 at 20:51
-
7The difference between them is that components that their value is set/passed and have a callback are called `controlled components` (``) vs. traditional HTML where an input element handle their own value and can be read via `refs` called `uncontrolled components` (`
`). Controlled components are managing their own state via `setState` or getting it from their parent component as props. – Lior Elrom Feb 12 '19 at 13:13 -
How would you call a component that gets it `defaultValue` through props, but which notifies the controller `onBlur`? – Paul Razvan Berg Dec 05 '19 at 12:04
-
@PaulRazvanBerg That sounds like an anti-pattern, [state should be controlled in a single place](https://reactjs.org/docs/thinking-in-react.html#step-4-identify-where-your-state-should-live). Usually you will [lift state](https://reactjs.org/docs/lifting-state-up.html) to the closest common ancestor. – Aaron Beall Dec 05 '19 at 18:00
-
Yeah, so that's I'm doing, I'm lifting the state on `onBlur`. – Paul Razvan Berg Dec 05 '19 at 23:03
-
@PaulRazvanBerg I probably don't quite understand your setup, perhaps make a SO question and at-mention me. – Aaron Beall Dec 05 '19 at 23:12
-
There you go, Aaron: https://stackoverflow.com/questions/59204630/is-this-a-controlled-or-uncontrolled-react-component – Paul Razvan Berg Dec 05 '19 at 23:18
-
Are there any pros to using uncontrolled components, is there any performance difference? – Lasantha Basnayake Jan 16 '20 at 17:48
-
1A component that doesn't take any props or don't have any state is also an uncontrolled component. – sujeet Dec 17 '20 at 03:47
-
need edit?....... – Snowmanzzz Nov 17 '21 at 01:42
-
I have a question about this. What if the child component has to take state from parent but also keep internal state for functionality that the parent really doesn't need to be concerned with and only notifies parent of ```certain``` events? Say instead of a simple input it's a custom child component with lots of different behavior/state. Is that still controlled right? Iow, child receives data from parent and when child is displayed it shows that initially but the user can do other things that the child has logic for and then updates parent only when user has "ok'd" Is that controlled – MattoMK Sep 01 '22 at 14:54
-
1This answer is not accurate and doesn't reflect the information from the docs it links to. Control does not refer to a parent managing a child through props but that form data is managed using React state. An uncontrolled component's form data is managed by the DOM similar to a normal HTML form (achieved in React through the use of refs). – ElwoodP Mar 15 '23 at 12:28
-
@ElwoodP Not sure what you are trying to distinguish, the docs say "...the React component that renders a form also controls what happens in that form on subsequent user input [by setting props on the child]. An input form element whose value is controlled by React in this way is called a “controlled component”." If you are pointing out that the parent might store the form data in its own state, that's irrelevant to what makes the child a "controlled component". – Aaron Beall Mar 16 '23 at 17:31
-
@AaronBeall Many apologies, I made a mistake . I agree that what you say is correct. – ElwoodP Mar 16 '23 at 21:59
They both render form elements
Uncontrolled component and Controlled component are terms used to describe React components that render HTML form elements. Every time you create a React component that renders an HTML form element, you are creating one of those two.
Uncontrolled components and Controlled components differ in the way they access the data from the form elements (<input>
, <textarea>
, <select>
).
Uncontrolled Components
An uncontrolled component is a component that renders form elements, where the form element's data is handled by the DOM (default DOM behavior). To access the input's DOM node and extract its value you can use a ref.
Example - Uncontrolled component:
const { useRef } from 'react';
function Example () {
const inputRef = useRef(null);
return <input type="text" defaultValue="bar" ref={inputRef} />
}
Controlled Components
A controlled component is a component that renders form elements and controls them by keeping the form data in the component's state.
In a controlled component, the form element's data is handled by the React component (not DOM) and kept in the component's state. A controlled component basically overrides the default behavior of the HTML form elements.
We create a controlled component by connecting the form element (<input>
, <textarea>
or <select>
) to the state by setting its attribute value
and the event onChange
.
Example - Controlled Component:
const { useState } from 'react';
function Controlled () {
const [email, setEmail] = useState();
const handleInput = (e) => setEmail(e.target.value);
return <input type="text" value={email} onChange={handleInput} />;
}

- 1,938
- 3
- 24
- 33
-
7I think this answer is better than the accepted one. Cleared my thoughts. Upper one is little bit confusing for me – Maddy8381 Jan 24 '22 at 15:32
-
1This is by far the best and most straightforward answer I've come across.. thank you @ross_u! – Ankit_M Apr 22 '22 at 05:27
-
2@Maddy8381 The accepted answer is simply not correct. A controlled component has nothing to do with being managed by its parent through props. It refers to form data being managed by React state as described in this answer. – ElwoodP Mar 15 '23 at 12:38
-
@ElwoodP I think you actually have this backwards. A controlled component has nothing to do with how the parent manages the state, it might be in the parent's state, it might further up, it might be in Redux, it might be some other state management strategy... the "controlled" aspect refers to the *form element component* not having its own state, and being controlled by external props. – Aaron Beall Mar 16 '23 at 17:53
-
@AaronBeall Many apologies, I made a mistake . I agree that what you say is correct. – ElwoodP Mar 16 '23 at 21:59
Controlled component is component that get the changed value from the callback function and uncontrolled component is component that have the one from the DOM. For example, When input value is changed,we can use onChange function in Controlled Component and also we can get the value using DOM like ref.
Controlled components do not hold their state.
Data they need is passed down to them from a parent component.
They interact with this data by callback functions, which are also passed from the parent to the child.

- 185
- 8
TLDR;
https://www.youtube.com/watch?v=6L2Rd116EvY You can check that page out he explains it finely.......
Controlled Components
Without complex words, Controlled components are components rendering form elements such as <input/>
whose value is controlled by react and react alone, For example copy the code below and try to change the input field within the DOM...
export default function Component() {
return (
<div>
<input type="text" value="somevalue" />
</div>
)
}
No matter how much you try to update the value of the input above, react won't let you. Because Reacts wants to be the one in control of the updated value using states hence the title controlled...
It's value can be updated by connecting the attributes onChange
and value
to a state as shown below, Try it out.
function Component() {
const [text,setText] = React.useState("")
return (
<div>
<input type="text" onChange={(e)=>setText(e.target.value)} value={text} />
<p>{text}</p>
</div>
)
}
Now our input can be updated and its value, used either to render something or perform instant validation....
Uncontrolled Components
Uncontrolled components are components that render form elements such as <input/>
whose value can be handled by the Dom element and one major difference between controlled and uncontrolled is the value attribute definition. for uncontrolled, we have a defaultValue
instead or no value at all sometimes..
function Component() {
return (
<div>
<input type="email" id="message" defaultValue="example@mail.com" />
</div>
)
}
The value of the input above can be changed and is controlled by the DOM without React...
Its advice to use the Controlled Components more in react as you can perform instant validation and enforce dynamic inputs.

- 51
- 6
A controlled component is a preferred way to do things in React.
It allows us to keep all component states in the React state, instead of relying on the DOM to retrieve the element's value through its internal state.
A controlled component is a component that derives its input values from the state.

- 1,901
- 5
- 16
- 27

- 21
- 1
Controlled components are mainly those where any prop value of the component is either from the parent component or from the store (as in case of redux). Example:
<ControlledComp value={this.props.fromParent}/>
In case of an uncontrolled component, the component value can be taken from the state of the component depending on the event handling. Example:
<UncontrolledComp value={this.state.independentValue}/>

- 9,137
- 11
- 75
- 83

- 69
- 2
-
10This doesn't explain the concept. Please take help from other answers or simply delete this answer – salvi shahzad Oct 06 '21 at 04:41