React JS Tutorial : What is React functional components ?

Опубликовано: 04 Июль 2026
на канале: Techaly Code
4
0

Today we're talking about React functional components. A functional component is written as a JavaScript function and is used to build reusable UI components. It typically takes in props, and returns a React element.

Let’s look at an example. Here's some code for a simple react button component. It’s a functional component that takes in props such as btnText and btnType, and renders a button with the corresponding text and style.

Now let's look at another example of a functional component that renders a username in an h2 tag. This component takes in props called name, and renders it within an h2 tag.

Functional components are often simpler than class components because they don't need life cycle methods or local state. So when building components, it's generally recommended to use functional components unless you need features from a class component.

To sum it up, React functional components are created by writing JavaScript functions. They take in props, and return a React element. They are simpler than class components and are often used when building apps.

That's it! Hopefully this gave you an overview of what React functional components are and how to use them. Thanks for joining us!