AceDevHub
Beginner React Interview QuestionsBeginnerComparison

React · Question 4

What is the difference between function components and class components in React?

Direct answer

Function components are ordinary functions that return JSX and use Hooks for React features; class components use React.Component and lifecycle methods and are mainly encountered in older code.

FeatureFunction componentClass component
DefinitionJavaScript functionClass extending React.Component
State and React featuresHooks such as useState and useEffectthis.state and lifecycle methods
this bindingNot requiredOften relevant
New React codeStandard approachSupported, but mostly legacy/maintenance

Modern React documentation teaches function components first. Hooks are designed for function components and cannot be called inside class components.