Do I need both clsx
and twMerge
?
#379
-
Hey gang Something has been bugging me for a while now. Whenever we talk about TwMerge we talk about it's performance compared to I've most commonly seen it used in combination with export function cn(...args: ClassValue[]) {
return twMerge(clsx(...args));
} But what bothers me is that I can't find any reference from anyone who actually knows what they are talking about - do I need both? Do we get some performance benefit by having clsx do the first concat? Why would someone propose this if not, are there any other reasons? 🤷 Any information is welcome |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Here's a really good video about it: https://www.youtube.com/watch?v=re2JFITR7TI Haven't used it myself yet though. Good luck! |
Beta Was this translation helpful? Give feedback.
Yes, you are right. I believe some people wanted to use the object syntax which tailwind-merge doesn't support and then everyone else copied that piece of code. 😅
If you don't use the object syntax, you don't need the
clsx
part.twMerge
supports everything thatclsx
does except objects. I also believe you shouldn't use the object syntax when using Tailwind CSS classes.