PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

React · Theory

Constructor in Function Components

← All stacks

Theory

77/94

Constructor in Function Components

There is no constructor in a function component. People search this because class tutorials burned the word in. Initial state is the first argument to useState. Expensive init: useState(() => createRows()). That function runs once.

Mount work (subscribe, fetch, focus) is useEffect, not a constructor body. Saying ‘functional constructor’ in a viva without this correction sounds confused.

Constructor in Function Components — on screen: 0. First useState argument is the initial value — that is the ‘constructor’.

Diagram
Parent
    │ props (read-only)
    ▼
  Child → UI
Exam tip

useState initial ≈ class constructor state.

Example

// No constructor
import { useState } from "react";

export default function Box({ start = 0 }) {
  const [n] = useState(start);
  return <p>{n}</p>;
}

Constructor in Function Components — on screen: 0. First useState argument is the initial value — that is the ‘constructor’.

Short notes

  • DefNo constructor.
  • RuleInit : useState(value) or lazy fn.
  • RememberMount : useEffect.

Questions

1

Explain Constructor in Function Components as if you are teaching a junior — definition, then one tiny UI.

2

What does the example show on screen (or print), and what does that prove?

3

What mistake do freshers make with Constructor in Function Components?

Previous← Conditional Classes in ReactNextString to Component in React →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.