loading...

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

FULL DISCUSSION
 

I remember ditching classnames long ago. At some point we've decided that vendor for joining strings is an overkill. I think we've used something like this (pseudocode):

const cls = (input: string|boolean[]): string => input.filter((cond: string | boolean) => typeof cond === "string").join(", ");

<div className={cls(["one", isTrue ? "two" : "three", isAnything && "four"]) />

And it worked perfectly. You could drop the filter element, but then you'll get false as one of the classes from time to time.

code of conduct - report abuse