DEV Community

Discussion on: You do not need to use the classnames package

Collapse
 
pallymore profile image
Yurui Zhang
`${ false ? '' : 'foo-bar'}` // => ''
Enter fullscreen mode Exit fullscreen mode

this should return 'foo-bar' instead of ''.

For simple use cases classnames is definitely an overkill, but I would say if you have more than 2 conditions in the same template literal it becomes ugly really quickly.

Also there is a smaller package for the same purpose called clsx.

Collapse
 
nickytonline profile image
Nick Taylor • Edited

Thanks, correction made. Yes, agreed that it could get unwieldy, just showing another way of doing things is all. 😉