DEV Community

SELVAKUMAR R
SELVAKUMAR R

Posted on

What is JSX? Why we use in React ?

JSX - JAVA SCRIPT XML

XML - Extensible Markup Language

JSX allow the user to write the html code with in the java script code

It is used in the React JS for creating the user interface

The JSX code is not directly understood by browser in that Babel tool convert the JSX code in to normal Java Script code

Example:

import React from "react";

function App() {
   const name = 'Selva';
    const greeting = <h1>Hello, {name}!</h1>;


    return <h1>{greeting}</h1>;
}

export default App;
Enter fullscreen mode Exit fullscreen mode

Output:

Hello, Selva!

Top comments (0)