REACT

Learn React: Advanced JSX and Everything Else You Need To Know

Part 2 of Learn React from Scratch Series

Aphinya Dechalert
Modules&Methods
Published in
6 min readNov 4, 2021

--

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:

--

--

Aphinya Dechalert
Modules&Methods

Where Development Meets Storytelling: Tech Writer, Editor & Dev Advocate. Translating Complexity into Clarity. DM me. linkedin.com/in/dechalert