Passing arrays to cx results in a className string with commas
See original GitHub issuesample code here: https://github.com/brianbegy/classnames-array-poc
const cx = require("classnames");
function returnsAnArray() {
return ["arrays", "have", "commas"];
}
console.log(cx("strings", { ["are"]: true }, { ["ok"]: true }));
console.log(cx("but", { [returnsAnArray()]: true }));
expected result:
strings are ok
but arrays have commas
actual result:
strings are ok
but arrays,have,commas
Is this the intended behavior?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
How to add multiple classes to a ReactJS Component?
I use classnames when there is a fair amount of logic required for deciding the classes to (not) use. An overly simple example:...
Read more >JavaScript Tutorial: The Basics
split(delimiter): returns an array by splitting the string using delimiter . Searching/Modifying Strings using Regular Expression: See "Regular ...
Read more >D3 Basics - D3 - A Beginner's Guide to Using D3
data() is called it iterates over the array and passes each value down the method chain. 5 gets joined with the first <circle>...
Read more >5. Working with Arrays and Loops - JavaScript Cookbook [Book]
For instance, if you create an array literal, you can use commas to delimit array elements that don’t yet exist: var arrLiteral =...
Read more >fitcecoc - Classification - MathWorks
The cross-validation results determine how well the model generalizes. ... By default, when you pass tall arrays to fitcecoc , the software trains...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@brianbegy the default behavior of JavaScript is:
The commas seem to be something related to JavaScript, and not this package.
Having looked through the code and written a solution, it is pretty obvious that “fixing” it would have a serious performance cost.
I’ll leave this open for the moment, but this looks like a “won’t fix” to me.