Question presented to candidate: "What is JSX, and what actually happens to it before the browser runs your code?"
What a strong answer should cover:
- JSX is an XML-like syntax extension to JavaScript, not HTML and not a template language.
- Browsers cannot run it — a compiler (Babel, SWC, oxc, TypeScript) turns it into plain function calls at build time.
- Under the modern automatic runtime it compiles to
jsx()/jsxs()auto-imported fromreact/jsx-runtime; the older classic runtime compiled toReact.createElementand requiredReactto be in scope. - The calls return elements — plain objects — so JSX produces data, it does not render anything.
- Capitalisation matters: lowercase names compile to strings (host elements), capitalised ones to the identifier itself.
- It is an expression, so it can be assigned to variables, returned, and put in arrays.
- Attribute differences:
className,htmlFor, camelCased event handlers,styleas an object. - Security: interpolated values are escaped, which is why
dangerouslySetInnerHTMLhas to exist and is named that way. - Depth signal:
keyis compiled to a separate argument, not into props — which is whyprops.keydoes not exist.
Clarifying questions expected:
- "Do you want the syntax rules, or what it compiles to?"
Code / implementation expected: Optional, but showing the compiled output next to the source is the strongest version of this answer.