React Components
The building blocks of React applications.

Components are the heart of React. They let you split the UI into independent, reusable pieces, and think about each piece in isolation. Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called “props”) and return React elements describing what should appear on the screen.

There are two main types of components in React, though modern React development heavily favors one:

  • Function Components: These are simple JavaScript functions that accept props and return React elements. With the introduction of Hooks, function components can now manage state and side effects, making them powerful and concise.
  • Class Components: These are ES6 classes that extend `React.Component`. They have a `render()` method that returns React elements, and can manage state and lifecycle methods. While still supported, new development generally prefers function components.
Test Your Knowledge