Add a class like this in react
<body>
</body>
I am expected the code bellow
<body >
</body>
CodePudding user response:
use "className instead class
CodePudding user response:
You can use a conditional statements to add or append classes like this:
<body className={isDarkState ? "dark" : null}>
</body>
Also, change the class
to className
as class
is a Javascript keyword.
class is a keyword in JavaScript, and JSX is an extension of JavaScript. That's the principal reason why React uses className instead of class. Pass a string as the className prop.