A React function component is a plain JavaScript function that accepts a props object and returns JSX describing what should appear on screen. To create one, write a function whose name starts with a capital letter, return markup from it, and use it in JSX like an HTML tag, for example <Greeting />. Function components are the standard way to build React user interfaces today, and every React 19 feature, including Hooks, is designed for them.
If you know JSX, you already know how to write markup inside JavaScript. A component simply wraps that markup in a function so you can name it, reuse it and give it inputs.
A component is a reusable piece of user interface. In React, you build a page by combining many small components, such as a header, a button and a product card, into a tree.
A function component has three properties:
null, or an array of those.Class components (class App extends React.Component) still work, but they are legacy. New code uses function components, and this guide uses them throughout.
Here is the smallest useful component, written as a function declaration:
The function runs every time React needs to render the component, and whatever it returns becomes part of the page. You can use the component from another file by placing it in JSX:
Each <Greeting /> is an independent instance of the same component. Rendering it twice produces two <h1> elements. A related article covers how export and import connect files like these.
Both styles define a valid component. Choose one and stay consistent in a project.
| Style | Hoisted | Typical use |
|---|---|---|
| Function declaration | Yes | Top-level components in a file |
Arrow function in a const | No | Short components, inline helpers |
| Arrow function with implicit return | No | One-line components |
A function declaration is hoisted, so you can use it above its definition in the same file. A const arrow function cannot be used before the line that defines it.
JSX uses the first letter to decide what a tag means. A lowercase tag such as <div> is treated as a built-in HTML element. An uppercase tag such as <Greeting /> is treated as a reference to a variable in scope, which must be your component.
If you write <greeting />, the browser receives an unknown HTML element and your component never runs. Always name components in PascalCase, and name the file after the component, for example Greeting.jsx.
A component must return one root element. If you need to return several siblings, wrap them in a parent element or in a Fragment (<>...</>), which a related article covers.
Put parentheses around multi-line JSX after return. Without them, JavaScript inserts a semicolon after return on its own line and the function returns undefined.
React also expects a component to be pure: given the same props and state, it should return the same JSX, and it should not change variables outside itself while rendering. Do side effects such as network requests inside event handlers or useEffect, never directly in the body of the function.
Props are the arguments of a component. React passes them as a single object, and you usually destructure it in the parameter list:
The default value "Member" applies when the caller leaves role out. Props are read-only: a component must never modify the props it receives. Related articles cover props in depth.
Greeting() instead of <Greeting />. Calling it directly skips React's rendering machinery and breaks Hooks.Yes. Return null and React renders nothing for that component. This is a common way to hide a component conditionally.
No. Modern build tools use the automatic JSX transform, so you do not need import React from "react" just to write JSX. You only import what you use, such as useState.
Either works the same way in React. Pick one style for your team; declarations are hoisted, while arrow functions are slightly shorter for small components.
A class component uses render() and lifecycle methods, while a function component is just a function that uses Hooks for state and effects. Function components are simpler and are the recommended approach.
A React function component is a capitalised JavaScript function that returns JSX. Name it in PascalCase, return a single root, keep the function pure, and use it in JSX as <Name />. Give it inputs through props, and avoid calling it directly or defining it inside another component.