What is a React component?

Why Interviewers Ask This

Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for React.js development. It reveals whether you understand the building blocks that more complex concepts rely on.

Answer

A React component is a reusable, self-contained piece of UI. Components are the fundamental building blocks of React applications — you compose them together to build complex interfaces. Modern React uses function components: plain JavaScript functions that accept props as an argument and return JSX: function Welcome({ name }) { return <h1>Hello, {name}!</h1>; }. Class components (legacy): extend React.Component and implement a render() method. Components must start with an uppercase letter so React knows to treat them as components rather than plain HTML elements. Components can contain other components (composition), manage their own state with hooks, and receive data from parents via props. The component tree forms the structure of your application. There is no hard rule for how large a component should be — generally, a component should do one thing well. Components promote code reuse, separation of concerns, and easier testing.

Pro Tip

Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a React.js codebase.