What is JSX

React uses the JSX syntax. JSX is an extension of the JavaScript syntax and can be interpreted as a combination of JavaScript and XML. JSX allows us to write HTML code in JS.

Second, use JSX

JSX syntax is already used in the app.js we created in the previous section

In JS we’re writing HTML tags, which we haven’t done before.

We can also put the tag we want to render into a variable, such as const element =

hahahaha

, and put that variable into the render function

Run the project to see our content

Three, style,

In JSX syntax, we need to define a class for the tag. Instead of adding a class to the tag, we need to write className=” XXX “.

You can also declare an object and assign it to style as an inline style

4. JavaScript expressions

JavaScript expressions can be used in JSX and are written in {}.