REACT
Learn React: Advanced JSX and Everything Else You Need To Know
Part 2 of Learn React from Scratch Series
Previously on Learn React from Scratch Series:
JSX is easy once you’ve got the syntax down. If you’ve got experience or knowledge in JavaScript, JSX is pretty easy to pick up quickly. Here are more JSX syntaxes that you should know to be an effective React developer.
class and className
In HTML, class
is used as an attribute that lets the browser know which CSS
class to apply. However, class
is also a JavaScript reserved word.
JSX compiles down into JavaScript, which means that conflicts can occur. To fix this, we use the attribute className
instead of class
. Don't worry, it will compile into the HTML class
attribute during the build process. The differences between className
and class
is simply to help JSX determine what kind of class we're dealing with.
Here is an example:
const greeting = "hello";
<h1…