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

When working with forms in React, you’ll come across controlled and uncontrolled components. Let’s break it down 👇

📌 Controlled Component
The form data is handled by React state.

function App() {
const [name, setName] = useState(“”);
return (


This content originally appeared on DEV Community and was authored by Aman Kureshi

When working with forms in React, you’ll come across controlled and uncontrolled components. Let’s break it down 👇

📌 Controlled Component
The form data is handled by React state.

function App() {
  const [name, setName] = useState("");
  return (
    <input 
      value={name} 
      onChange={(e) => setName(e.target.value)} 
    />
  );
}

âś… React fully controls the input.

📌 Uncontrolled Component
The form data is handled by the DOM itself using ref.

function App() {
  const inputRef = useRef();
  return (
    <input ref={inputRef} />
  );
}

✅ Useful when you don’t need to track every change.

✨ Key Difference:
• Controlled → State managed by React.
• Uncontrolled → State managed by DOM.

👉 Rule of thumb: Use controlled components when you need form validation or dynamic updates. 🚀


This content originally appeared on DEV Community and was authored by Aman Kureshi


Print Share Comment Cite Upload Translate Updates
APA

Aman Kureshi | Sciencx (2025-08-31T13:29:15+00:00) 🎨 Controlled vs Uncontrolled Components in React: What’s the Difference?. Retrieved from https://www.scien.cx/2025/08/31/%f0%9f%8e%a8-controlled-vs-uncontrolled-components-in-react-whats-the-difference/

MLA
" » 🎨 Controlled vs Uncontrolled Components in React: What’s the Difference?." Aman Kureshi | Sciencx - Sunday August 31, 2025, https://www.scien.cx/2025/08/31/%f0%9f%8e%a8-controlled-vs-uncontrolled-components-in-react-whats-the-difference/
HARVARD
Aman Kureshi | Sciencx Sunday August 31, 2025 » 🎨 Controlled vs Uncontrolled Components in React: What’s the Difference?., viewed ,<https://www.scien.cx/2025/08/31/%f0%9f%8e%a8-controlled-vs-uncontrolled-components-in-react-whats-the-difference/>
VANCOUVER
Aman Kureshi | Sciencx - » 🎨 Controlled vs Uncontrolled Components in React: What’s the Difference?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/08/31/%f0%9f%8e%a8-controlled-vs-uncontrolled-components-in-react-whats-the-difference/
CHICAGO
" » 🎨 Controlled vs Uncontrolled Components in React: What’s the Difference?." Aman Kureshi | Sciencx - Accessed . https://www.scien.cx/2025/08/31/%f0%9f%8e%a8-controlled-vs-uncontrolled-components-in-react-whats-the-difference/
IEEE
" » 🎨 Controlled vs Uncontrolled Components in React: What’s the Difference?." Aman Kureshi | Sciencx [Online]. Available: https://www.scien.cx/2025/08/31/%f0%9f%8e%a8-controlled-vs-uncontrolled-components-in-react-whats-the-difference/. [Accessed: ]
rf:citation
» 🎨 Controlled vs Uncontrolled Components in React: What’s the Difference? | Aman Kureshi | Sciencx | https://www.scien.cx/2025/08/31/%f0%9f%8e%a8-controlled-vs-uncontrolled-components-in-react-whats-the-difference/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.