Props vs Attributes: JSX Transformation
What you'll learn: How JSX props are transformed into JavaScript objects that React components receive.
The Transformation Process
When you write JSX, you're writing what looks like HTML attributes, but React transforms them into something different. Every prop you pass in JSX becomes a property in a plain JavaScript object that your component receives.
Here's what happens behind the scenes:
// What you write in JSX:
<Greeting name="Alice" age={25} />
// What React transforms it into:
React.createElement(Greeting, { name: "Alice", age: 25 })
Notice that React.createElement takes three arguments:
- The component (or HTML tag)
- An object containing all the props
- Children (not shown here)
Why This Matters
Understanding this transformation explains several things you've already learned:
- Props are just object properties — that's why you access them with dot notation (
props.name) - Props are grouped together — React bundles them into a single object, the second argument to
createElement - String values work without braces — JSX shortcuts them, but they still become object properties
Think of JSX as syntactic sugar. You're essentially calling a function, but JSX makes it look like markup for readability.
The Mental Model
JSX attribute syntax → JavaScript object → Your component's props parameter
Every time you add a prop in JSX, you're really just adding another key-value pair to that object React will pass to your component.
Key Takeaway: JSX props aren't HTML attributes—they're JavaScript object properties. React.createElement receives them as the second argument, bundled into a single props object.