What is a Function Component?
You'll learn: The fundamental building block of React UIs — a JavaScript function that accepts data and returns what you want to show on screen.
The Core Idea
A function component is simply a JavaScript function that returns JSX. That's it. You write a function, and instead of returning a number or string, you return the JSX that describes what should appear in the browser.
Think of it like a recipe card. You give the recipe some ingredients (we call these "props"), and it tells you exactly what dish to make. Every time you use that recipe, you get a consistent result based on the ingredients you provided.
The Basic Pattern
function Greeting() {
return <h1>Hello, World!</h1>;
}
This is a complete, valid React component. It's a function named Greeting that returns JSX describing a heading element. You can now use <Greeting /> anywhere in your React app.
With Props (Data Inputs)
function Greeting(props) {
return <h1>Hello, {props.name}!</h1>;
}
Here, the function accepts props (short for "properties") — an object containing data passed from the parent. This makes components flexible and reusable.
Why Functions?
Before React popularized this pattern, components were often classes with complex boilerplate. Function components are simpler: input (props) → output (JSX). They're easier to read, test, and reason about.
Key Takeaway: A function component is a JavaScript function that accepts props and returns JSX — the simplest, most fundamental way to build reusable pieces of UI in React.