Lesson
Manage React component classes with classnames npm package
When developing React apps it's common that we have components that need to have different classes depending on different conditions. In such complex scenarios, we often end up with a whole lot of if statements (or switches) just to set proper CSS classes to...
- Duration
- 2 min
- Access
- Free
- Transcript
- Needs source
When developing React apps it's common that we have components that need to have different classes depending on different conditions. In such complex scenarios, we often end up with a whole lot of if statements (or switches) just to set proper CSS classes to a component.
Luckily, there is a utility npm package to help us with that - classnames. In this lesson, we are going to learn how to use classnames package to manage setting different classes to a Message component in an easy and maintainable way.