Why use JSX?

Question

Why use JSX?

Answer

Without the use of JSX React uses the React.createElement() function over and over to build elements out of data passed to the function. With JSX we can describe what our user interface should look like by writing HTML like JavaScript in our JS files which will compile to multiple calls to React.createElement() behind the scenes. This functionality that JSX gives us, allows our code to be more DRY (Don’t Repeat Yourself), scales better, and separates concerns as opposed to separating technologies.

1 Like