React
frontendreactGuideBeginner
React Components & Function Architecture
Building React components: functional components, return requirements, PascalCase naming, component purity, and folder organization.
Verified: 2026-09-30
Tested on:react 19.x
Platforms:
web
#react#components#functional-components#purity
React Components & Function Architecture
In modern React, a component is simply a JavaScript function that accepts props (inputs) and returns JSX markup describing what should appear on the screen.
1. Anatomy of a Function Component
interface ArticleCardProps {
title: string;
category: string;
}
export function ArticleCard({ title, category }: ArticleCardProps) {
return (
<article className="p-4 rounded border bg-card">
<span className="text-xs uppercase text-primary">{category}</span>
<h3 className="text-lg font-bold mt-1">{title}</h3>
</article>
);
}2. Component Rules
- Must Start with a Capital Letter (PascalCase): React distinguishes native HTML elements (
<div>,<button>) from custom components (<ArticleCard>,<Header>) by capitalization. - Must Return a Single Root Element: Components cannot return multiple sibling elements without wrapping them in a parent container or a Fragment (
<>...</>). - Must Be Pure Functions: Given the same inputs (
props), a React component should always return the same JSX without mutating external variables during rendering.
Related Topics
React Project Setup (Vite & Next.js)
How to initialize a modern React project: creating a Vite SPA or a Next.js App Router full-stack application with TypeScript and Tailwind CSS.
JSX (JavaScript XML) Syntax Guide
Mastering JSX: syntax rules, embedding JavaScript expressions with curly braces {}, Fragments, className, and style objects.