1.

What is JSX?

Answer»

JSX stands for JAVASCRIPT XML. It allows US to write HTML inside JavaScript and place them in the DOM without using functions like appendChild( ) or createElement( ).

As stated in the official DOCS of React, JSX provides syntactic sugar for React.createElement( ) function.

Note- We can create react applications without using JSX as well.

Let’s understand how JSX WORKS:

Without using JSX, we would have to create an element by the following process:

const text = React.createElement('p', {}, 'This is a text');const container = React.createElement('div','{}',text );ReactDOM.render(container,rootElement);

Using JSX, the above code can be simplified:

const container = (<div> <p>This is a text</p></div>);ReactDOM.render(container,rootElement);

As one can see in the code above, we are directly using HTML inside JavaScript.



Discussion

No Comment Found