Define an HTML Class in JSX..Here Div has a class too but still showing error.Why?

Define an HTML Class in JSX..Here Div has a class too but still showing error.Why?
0

#1

Tell us what’s happening:

Your code so far


const JSX = (
  <div class= "myDiv">
    <h1>Add a class to this div</h1>
     </div>
);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/define-an-html-class-in-jsx


#2

Because class is a reserved word in JS, in React JSX, you have to call it className. Yes, it’s a bit odd, but you get used to it.

It was explained in the instructions:

One key difference in JSX is that you can no longer use the word class to define HTML classes. This is because class is a reserved word in JavaScript. Instead, JSX uses className.