InterviewHubPRO
Section Overview
Q4

Question 4 of 445

Part 1: Core React, JSX & Component Architecture (1 - 77)

1%
React & Modern Frontend (445 Qs)•Part 1: Core React, JSX & Component Architecture (1 - 77)

What is JSX?

JSX stands for JavaScript XML and it is an XML-like syntax extension to ECMAScript. Basically it just provides the syntactic sugar for the React.createElement(type, props, ...children) function, giving us expressiveness of JavaScript along with HTML like template syntax.

In the example below, the text inside <h1> tag is returned as JavaScript function to the render function.

jsx
export default function App() {
return <h1 className="greeting">{"Hello, this is a JSX Code!"}</h1>;
}

If you don't use JSX syntax then the respective JavaScript code should be written as below,

javascript
import { createElement } from "react";

export default function App() {
return createElement(
 "h1",
 { className: "greeting" },
 "Hello, this is a JSX Code!"
);
}
<details><summary><b>See Class</b></summary> <p>
jsx
class App extends React.Component {
render() {
 return <h1 className="greeting">{"Hello, this is a JSX Code!"}</h1>;
}
}
</p> </details>

Note: JSX is stricter than HTML