JSX
Characteristics of JSX
JSX or JavaScript XML is an extension to the JavaScript language syntax.
Allows you to write XML-like code for elements and components
JSX tags have a tag name, attributes and children
Not necessary to write React applications
Makes React code simpler and elegant
Ultimately transpiles to pure JavaScript which is understood by the browsers
Using JSX vs. without JSX
Without JSX, the above code would look like this:
As you can see, JSX is a much simpler approach. JSX translates into React.createElement, which is imported by the React library.
Differences between JSX and HTMl
class -> className
for -> htmlFor
camelCase property naming convention
onclick -> onClick
tabindex -> tabIndex
Last updated