Understanding JSX Rules
JSX is a syntax extension for JavaScript. It looks like a template language, but it comes with the full power of JavaScript.
1. Return a Single Root Element
To return multiple elements from a component, wrap them with a single parent tag. If you don't want to add extra <div> tags to your HTML, you can use a Fragment: <>...</>.
2. Close All The Tags
JSX requires tags to be explicitly closed: self-closing tags like <img> must become <img />, and wrapping tags like <li>oranges must be written as <li>oranges</li>.
3. camelCase Most Things!
JSX turns into JavaScript and attributes written in JSX become keys of JavaScript objects. Therefore, JSX uses camelCase for most attributes. E.g., class becomes className, and onclick becomes onClick.
Under the Hood+
Babel compiles JSX down to React.createElement() calls. This means JSX is basically syntactic sugar. Writing <h1 className="greeting">Hello</h1> is exactly the same as writing:React.createElement('h1', {className: 'greeting'}, 'Hello').
