lukeed / clsx

A tiny (239B) utility for constructing `className` strings conditionally.
MIT License
8.12k stars 140 forks source link

What's the difference with classcat #8

Closed vladshcherbin closed 5 years ago

vladshcherbin commented 5 years ago

Hey,

What's the difference with classcat package? It was also released as a faster/smaller/esm ready version of classnames a year ago.

Why another package with same purpose? It even has a benchmark where clsx seems to be many times slower. 🤔

Thanks

lukeed commented 5 years ago

Hey, thanks!

Classcat only works with a single parameter, which is an array of your values. This means it is 100% not compatible with classnames usage.

Clsx is a complete drop-in replacement for classnames. And if you look at my benchmarks (which are classnames' benchmarks) you'll see that Array-values are the worst case scenario for clsx. So what you're seeing is my worst case pinned against classcat's only case.

Hope that clears things up :)

vladshcherbin commented 5 years ago

@lukeed thanks for explanation :)