Functional Component
A functional component is a React component written as a plain JavaScript function that returns JSX. It is the modern, standard way to write components and can use Hooks for state and side effects.
React
Functional components replaced class components as the recommended style. They are simpler to read and write: the function receives props as its argument and returns the JSX to render.
With the introduction of Hooks like useState and useEffect, functional components can do everything class components could, including managing state and lifecycle behavior, while staying concise.
Examples
JSX — Renders a paragraph reading 'Hi, Ana!' when used with the name prop set to 'Ana'.
function Greeting(props) {
return <p>Hi, {props.name}!</p>;
}
// Used as: <Greeting name="Ana" />