To add multiple classes to a ReactJS Component, we can set the className
propt to a string with the classes separated by spaces.
For instance, we write
<li className={[activeClass, data.klass, "main-class"].join(" ")}>...</li>;
to join the activeClass
, data.klass
and 'main-class
strings together with join
.
Then all the classes are applied to the li element.