03 / 14

What’s the difference between an Element and a Component in React?

A React element describes what you want to see on the screen. simply put, a React element is a plain object describing what you want to appear on the screen in terms of the DOM nodes while components are either functions or classes which produce those react elements.

  1. 1

    Elements can contain other elements in their props.

  2. 2

    Creating a React element is cheap. Once an element is created, it is never mutated.

The object representation of React element would be as follows:
The above createElement returns as object as below
And finally it renders to the DOM using ReactDOM.render as below:
Difficulty: 5/10
Topics: React Elements, React Components, JSX

Scenario Questions

0-2 years experience
  1. 1

    If you need to render a button that just shows a label, would you create a React element directly in JSX or define a component? Walk me through how you'd do it.

  2. 2

    What happens if you call a component function without JSX, like MyComponent()? How does React treat the result compared to <MyComponent />?

2-5 years experience
  1. 1

    You notice that a list item is not updating when its props change. After inspecting, you see that you returned a plain object instead of a component. Explain why that caused the issue and how to fix it.

  2. 2

    During a refactor, you replace a class component with a functional component but keep using React.createElement directly. What differences should you be aware of between the element you create and the component definition?

5-8 years experience
  1. 1

    In a large codebase, some developers are mixing plain objects and components when building a UI library. How would you enforce a clear separation between elements and components to avoid bugs and improve performance?

  2. 2

    When implementing a virtualized list, you need to decide whether to store React elements or component types in the cache. Discuss the trade‑offs and impact on memory and rendering.

8+ years experience
  1. 1

    Your team is migrating a legacy codebase that heavily uses React.createElement with raw objects to a modern JSX/TSX approach. What architectural changes would you propose to standardize the distinction between elements and components across teams?

  2. 2

    At scale, you notice that a UI framework library ships both element factories and component classes, causing bundle bloat. How would you redesign the library's API to make the element/component boundary explicit and support tree‑shaking?

Follow-up Questions

  • Can you give an example of when you’d choose a functional component over a plain element?
  • How does React differentiate between a component and a DOM tag at runtime?
  • What implications does this distinction have for props handling?