Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • React Tutorial
  • React Exercise
  • React Basic Concepts
  • React Components
  • React Props
  • React Hooks
  • React Router
  • React Advanced
  • React Examples
  • React Interview Questions
  • React Projects
  • Next.js Tutorial
  • React Bootstrap
  • React Material UI
  • React Ant Design
  • React Desktop
  • React Rebass
  • React Blueprint
  • JavaScript
  • Web Technology
Open In App
Next Article:
Controlled vs Uncontrolled Components in ReactJS
Next article icon

Controlled vs Uncontrolled Components in ReactJS

Last Updated : 17 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Controlled components in React are the components whose state and behaviors are managed by React components using states while the uncontrolled components manage their own state and control their behaviors with the help of DOM.

In this article, we will explore the key differences between controlled and uncontrolled components in ReactJS, and how to decide which approach will best suit your project's need.

Difference Between Controlled and Uncontrolled Components

Here is a detailed comparison of Controlled and Uncontrolled Components based on various features

FeatureControlled ComponentsUncontrolled Components
State ManagementReact state manages the input valueDOM manages the input value
Data FlowReact → DOM (via props/state)DOM → React (via refs)
Value BindingInput value bound to state (value prop)Input value uncontrolled by React
Event HandlingonChange updates state on every changeAccess value on demand via ref
Form ValidationEasy to validate on each keystrokeValidation done on submit or on demand
ComplexityMore code (state + handlers required)Less code, simpler for quick forms
PerformanceMore re-renders due to state updatesFewer re-renders, potentially better performance
Use CasesComplex forms with real-time validationSimple forms or when instant control isn’t needed
SynchronizationEasy to sync with other UI elementsDifficult to keep in sync without extra work

What are Controlled Components?

A controlled component in React is an element whose state is controlled by React itself. This means that the component's state is stored in a React component's state and can only be updated by triggering a state change via React’s setState() method.

Features of Controlled

  • State Management: Form data is handled by the component's state using React's useState hook or this.state in class components.
  • Data Flow: The input elements' values are set by the state, and any changes are reflected through state updates.
  • Predictability: Since the state is managed by React, the component's behavior is predictable and consistent.
  • Real-Time Validation: Enables immediate validation and formatting of user input.
  • Single Source of Truth: The state serves as the single source of truth for the form data.

What are Uncontrolled Components?

An uncontrolled component in React refers to a component where the form element's state is not directly controlled by React. Instead, the form element itself maintains its own state, and React only interacts with the element indirectly through references (refs).

Features of Uncontrolled Components

  • DOM-Managed State: Form data is handled by the DOM itself, not by React state.
  • Use of Refs: Access to form values is achieved using React's useRef() or createRef() to reference DOM elements directly.
  • No State Management: Eliminates the need for state variables and event handlers for each input field.
  • Simpler Implementation: Suitable for simple forms or when integrating with non-React libraries that manipulate the DOM directly.
  • Less Predictable: Since the component's state is not synchronized with React, it can lead to less predictable behavior.
  • Manual Validation: Validation and formatting need to be handled manually, often during form submission.

Key Differences Between Controlled and Uncontrolled Components

  1. State Management:
    • Controlled: Uses React state as the source of truth.
    • Uncontrolled: Uses the DOM to maintain internal state.
  2. Data Flow:
    • Controlled: Data flows from React state to input.
    • Uncontrolled: Data flows from the input to React only when accessed via refs.
  3. Validation and Formatting:
    • Controlled: Can validate or format input in real-time.
    • Uncontrolled: Validation usually occurs on form submission.
  4. Complexity:
    • Controlled: Requires more boilerplate (state and handlers).
    • Uncontrolled: Simpler and quicker to implement for basic cases.
  5. Performance:
    • Controlled: May cause more re-renders, as each keystroke updates state.
    • Uncontrolled: Potentially better for large forms or infrequent value access.
  6. Use Cases:
    • Controlled: Complex forms, instant feedback, dynamic UI.
    • Uncontrolled: Simple forms, legacy code, quick prototypes.

Conclusion

Controlled components use React state for form handling, offering better control and updates, but with re-renderoverhead. Uncontrolled components rely on the DOM for state management, offering simplicity and performance for basic forms but with less control. Choose based on complexity and performance needs.


Next Article
Controlled vs Uncontrolled Components in ReactJS

A

aniluom
Improve
Article Tags :
  • Web Technologies
  • ReactJS
  • React-Questions

Similar Reads

    Uncontrolled Vs Controlled Inputs in React
    Controlled inputs are tied with the state in react and their values are stored controlled by the components using state variables, while the uncontrolled inputs manage their own state and work internally with the DOM.In HTML, form elements such as <input>, <textarea>, <select>, etc
    4 min read
    When to use an uncontrolled component in React?
    Uncontrolled Components are the components that are not controlled by the React state or any functions and are handled by the DOM (Document Object Model). So to access any value that has been entered we take the help of refs. In an uncontrolled component, the component manages its state internally.
    3 min read
    How to conditionally render components in ReactJS ?
    React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It’s ‘V’ in MVC. ReactJS is an open-source, component-based front-end library responsible only for the view layer of the application. It is maintained by Facebook.PrerequisitesNodeJS or NPMReact JSReact
    3 min read
    How to create components in ReactJS ?
    Components in React JS is are the core of building React applications. Components are the building blocks that contains UI elements and logic, making the development process easier and reusable. In this article we will see how we can create components in React JS. Table of Content React Functional C
    3 min read
    ReactJS Evergreen SegmentedControl Component
    React Evergreen is a popular front-end library with a set of React components for building beautiful products as this library is flexible, sensible defaults, and User friendly. SegmentedControl Component allows the user to toggle between a maximum of four options in a row. We can use the following a
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences