MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
Functional Components and Declarative UI0%
Study Materials
React.js for BeginnersProgress 0%
1.1Why React and Single-Page Architecture1.2Setting Up Modern React with Vite1.3React Project Directory Structure and Entry Points1.4Virtual DOM and React Render Cycle Explained
3.1Functional Components and Declarative UI3.2Component Props and Read-Only Data Flow3.3Destructuring Props and Default Prop Values3.4Passing Children and Composing Components
HomeTutorialsReact.js for BeginnersFunctional Components and Declarative UI
Component Props and Read-Only Data Flow

Functional Components and Declarative UI

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

1. What is a React Component?

In modern React, a component is a JavaScript function that accepts arbitrary inputs (called props) and returns a React element (written in JSX) describing how a section of the user interface should appear.

Components allow you to split the UI into independent, reusable pieces, and think about each piece in isolation.

1// A clean, modern functional component
2export default function CourseBadge({ title, duration }) {
3 return (
4 <div className="course-badge">
5 <span className="badge-title">{title}</span>
6 <span className="badge-time">{duration}</span>
7 </div>
8 );
9}

2. Capitalization Convention

In React, component names must always start with an uppercase letter (e.g., CourseCard, Header, UserProfile).

  • If an element starts with a lowercase letter (e.g., <div>, <span>, <button>), React treats it as a built-in standard HTML tag.
  • If an element starts with an uppercase letter (e.g., <CourseCard />), React recognizes it as a custom component and executes the corresponding JavaScript function.
1// ❌ Treated as an unknown HTML tag; will not invoke the function
2function button() {
3 return <button className="custom-btn">Click me</button>;
4}
5// Using <button /> invokes the standard HTML button, not your function
6 
7// ✅ Treated as a custom React component
8function CustomButton() {
9 return <button className="custom-btn">Click me</button>;
10}
11// Using <CustomButton /> invokes your custom function

3. Pure Functions and the Declarative Contract

React components are modeled after pure functions in computer science:

  • Same Inputs -> Same Output: Given the same props and state, a component should always return the exact same JSX.
  • No Side Effects During Render: A component function should simply describe what the UI should look like. It must not mutate external variables, modify the DOM directly, or start network requests inside the component body during rendering.
1// ❌ Impure Component: Mutates an external variable during rendering!
2let guestCount = 0;
3 
4export function Cup() {
5 guestCount = guestCount + 1; // Side effect during render!
6 return <h2>Tea cup for guest #{guestCount}</h2>;
7}
8 
9// ✅ Pure Component: Operates strictly on inputs (props)
10export function Cup({ guestNumber }) {
11 return <h2>Tea cup for guest #{guestNumber}</h2>;
12}

4. Class Components vs Modern Functional Components

Prior to React 16.8, complex components with state and lifecycle methods had to be written as ES6 Classes inheriting from React.Component:

1// Legacy Class Component (Older Codebases)
2class Welcome extends React.Component {
3 render() {
4 return <h1>Hello, {this.props.name}</h1>;
5 }
6}

Today, the entire React ecosystem has standardized on Functional Components with React Hooks:

  • Simpler Code: No this binding headaches, constructor methods, or class boilerplate.
  • Smaller Bundle Sizes: Functions minify and compress far better than JavaScript ES6 classes.
  • Code Sharing via Custom Hooks: Business and state logic can be extracted into reusable custom hooks without convoluted Higher-Order Component (HOC) or Render Prop patterns.

Interactive Quiz• Knowledge Check

Practice Quiz

Question 1
What rule must the naming of a React functional component strictly follow?
Question 2
What is the primary characteristic of a pure React component?
Question 3
What version of React introduced Hooks, transitioning the ecosystem from Class components to Functional components?
Question 4
Why are modern functional components preferred over legacy class components?
Question 5
What does a functional component return?
Next Lesson

Component Props and Read-Only Data Flow

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
React Fragments and Returning Clean MarkupComponent Props and Read-Only Data Flow

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master React.js for Beginners with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext