As a fresher , I face an interview question - How can we write React code without JSX?
Loading
As a fresher , I face an interview question - How can we write React code without JSX?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Raghunath BhukanPosted Jan 21, 2026, 11:28 AM
In React, JSX just simplifies the way you write or read code (Readable syntax) for
React.createElement. You can write React code without JSX by usingReact.createElementdirectly.1. Basic example with JSX
Normally, with JSX, you might write:
This JSX gets compiled to
React.createElementcalls behind the scenes.2. Equivalent code without JSX
Without JSX, you can write it like this:
Explanation:
React.createElement(type, props, ...children)type? HTML tag name or a React componentprops? an object containing properties/attributeschildren? the inner content or nested elementsNesting is done by passing other
React.createElementcalls as children.3. With props and events
For example, a button with a click handler:
Notice how you pass props as an object, including event handlers and styles.
JSX is optional. React works fine with plain JS using
React.createElement.Each JSX tag is just a shorthand for
React.createElement.Nesting elements requires calling
React.createElementrecursively for each child.