Professional Documents
Culture Documents
Learn React - JSX Cheatsheet - Codecademy
Learn React - JSX Cheatsheet - Codecademy
JSX
Nested JSX elements
In order for the code to compile, a JSX expression must
have exactly one outermost element. In the below block const myClasses = (
<h1>
Sign Up!
</h1>
</a>
);
ReactDOM.render(<h1>Render me!</h1>,
some example JavaScript code that will need to be
document.getElementById('app'));
compiled.
<li>item 1</li>
We see the closing parentheses on the line following the
<li>item 2</li>
end of the JSX expression.
<li>item 3</li>
</ul>
);
JSX className
In JSX, you can’t use the word class ! You have to use
className instead. This is because JSX gets translated // When rendered, this JSX expression...
into JavaScript, and class is a reserved word in const heading = <h1 className="large-
JavaScript. heading">Codecademy</h1>;
When JSX is rendered, JSX className attributes are
<h1 class="large-heading">Codecademy</h1>
<ul>{listItems}</ul>