Question presented to candidate: "What is a component in React, and what makes something a good one?"
What a strong answer should cover:
- A component is a reusable, self-contained piece of UI: a function that takes props and returns a description of what to render.
- Naming rule: must start with a capital letter, because lowercase JSX names compile to host-element strings.
- Function components are the modern default; class components are legacy but still supported and still required for Error Boundaries.
- Function components have no instance — there is no
this; state lives in Hooks keyed by call order. - Props are read-only. A component must never mutate them.
- Purity: given the same props and state, a component should return the same output and cause no side effects during render.
- Reuse is by composition, not inheritance — React has no component inheritance story at all.
- Components can return arrays, strings, numbers,
null, and Fragments — not just a single element.
Clarifying questions expected:
- "Function or class — is this a legacy codebase?"
- "Do you want the definition, or how I decide where to draw component boundaries?"
Code / implementation expected: Yes — a small component taking props, plus one composing another.