What is a component? What is the difference between a function and a class component?
Model answer
A component is a reusable piece of the UI. A function component is a JavaScript function that returns JSX. A class component is a class with a render method and lifecycle methods.
Modern React uses function components with hooks for almost everything. Class components still work and appear in older code, and error boundaries still need a class (or a library).
Learn this topic
React Components and Props Explained with Examples in the course React.js Full Course: Beginner to Advanced.
Sign in to add your own answer.