ReactIntermediate#forms

What are controlled and uncontrolled components?

A controlled input keeps its value in React state and updates through onChange, giving you validation and single-source-of-truth. An uncontrolled input keeps the value in the DOM and is read via a ref.

Example
// controlled
<input value={name} onChange={e => setName(e.target.value)} />
// uncontrolled
<input ref={inputRef} defaultValue="Anu" />

Related Questions

1
ReactIntermediate#fundamentals#performance

What is the virtual DOM and reconciliation?

Open
2
ReactBeginner#lists

Why do lists need keys?

Open
3
ReactBeginner#hooks#state

What is useState and how do you update state correctly?

Open