loading...

re: You do not need to use the classnames package VIEW POST

FULL DISCUSSION
 

Agreed, I think classNames is a bit of overkill for what is essentially concatenation of strings. However template literals can get hectic and hard to reason about very quickly. What I normally do is:

const componentClassName = [
  'some-base-class',
  someBooleanCondition && 'a-class-in-here',
  someOtherBoolean && 'another-class',
]
  .filter(Boolean)
  .join(' ')

Written on a mobile so forgive any typos!

code of conduct - report abuse