Skip to the page

How React renders · core

Components, elements and JSX

A component is a function that returns a description of the UI; JSX compiles to plain function calls that create element objects, and React (not you) calls your component later to render it.

The notes

What you must know

  • JSX compiles to jsx(type, props) calls from react/jsx-runtime (the "new JSX transform", which React 19 requires). The result is a plain object called a React element: roughly { type, props, key }.
  • A component is a function that takes props and returns React nodes: elements, strings, numbers, arrays, null. Its name starts with a capital letter, so JSX treats <Card /> as a component and <div /> as an HTML tag.
  • Creating an element does NOT call the component. React calls it later, during render. "Rendering" means React calling your function.
  • Three words: a React node is anything React can render; a React element is the object that <X /> creates; a component is the function X itself.
  • Props are read-only inputs. Data flows down through props; changes flow up through callback props (one-way data flow).
  • React 19: ref is a normal prop now, so element.ref is deprecated (read element.props.ref). propTypes and defaultProps on function components were removed; use TypeScript and default parameters.

The red pen

Common traps: mistake → fix

  • Mistake: "JSX is HTML inside JavaScript"

    Fix: it is syntax that compiles to function calls that return plain objects; that is why it uses className and htmlFor.

  • Mistake: "<Child /> calls Child immediately"

    Fix: it only creates an element object; React decides when, and how many times, to call Child.

  • Mistake: "{Child()} is the same as <Child />"

    Fix: calling it directly makes Child's hooks belong to the parent and removes its own identity, so its state and keys behave differently.

Easy to hard

Questions interviewers ask, easy to hard

  1. What is JSX and what does it compile to?
  2. What is the difference between a React node, a React element and a component?
  3. What does React actually do when it "renders" a component?
  4. Why is {Child()} different from <Child /> if both return the same JSX?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview