Hi there, I'm using a css-in-js library (stitches) which returns class names as objects with custom toString methods. This requires calling toString before passing the "class names" to clsx- otherwise clsx assumes the object is a config/mapping object.
// Current usage
const pink = css({ color: "pink" });
clsx(pink().toString())
I currently have a patch package which adds an additional check to the toVal function, checking to see if a mix object has it's own toString method and calls/returns that if so.
// General idea
if (mix.hasOwnProperty("toString")) {
str += mix.toString();
}
I noticed that classnames has a condition for this (original PR). React also calls toString if you pass an object to className. I'm wondering if it might be useful to include this behavior in clsx? I can contribute a PR if so.
Hi there, I'm using a css-in-js library (stitches) which returns class names as objects with custom
toStringmethods. This requires callingtoStringbefore passing the "class names" toclsx- otherwiseclsxassumes the object is a config/mapping object.I currently have a patch package which adds an additional check to the
toValfunction, checking to see if amixobject has it's owntoStringmethod and calls/returns that if so.I noticed that
classnameshas a condition for this (original PR). React also callstoStringif you pass an object toclassName. I'm wondering if it might be useful to include this behavior inclsx? I can contribute a PR if so.