How to have a dynamic class name
In same case, you may want to have a different style depend on your state or a variable. Now we can have two ways to achieve that.
classNames
This is a javascript for conditionally joining classNames.
Here is: Github
Basically, you can combine any number of classNames.
|
|
ES6 template literals
You can just use template literals.
|
|
Therefore when your write className in react:
|
|
I have an example in a simple react application(Github). The color of launch name is depend on whether it success or not.