class component
The older way to write a React component, as a JavaScript class with a render method and lifecycle methods.
In more detail
Function components with hooks have replaced classes for new code. Classes are still required for one job: an error boundary, because getDerivedStateFromError and componentDidCatch have no hook equivalent.
Related terms
- error boundary — A class component that catches errors thrown while rendering its children and shows a fallback UI instead of crashing the whole app.
- lifecycle method — A method of a class component that React calls at a particular moment, such as after mounting, after an update or after an error.
- component — A reusable, self-contained piece of interface, such as a card or a modal, with its own markup, styles and behaviour.
Taught in
- Rules of Hooks: Call Order, Hook Lists, And Fiber Storage — React 19 & Modern Component Architecture
- Code-Splitting with React.lazy: Dynamic Imports And Chunks — React 19 & Modern Component Architecture
- Error Boundaries: componentDidCatch And Fallback UI Trees — React 19 & Modern Component Architecture