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):
classnames
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.
filter
false
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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):And it worked perfectly. You could drop the
filter
element, but then you'll getfalse
as one of the classes from time to time.