Class names being returned as `[object Object]` as of v2.3.0
See original GitHub issueHi, first off - thank you for maintaining this fantastic package!
That said, we’ve run into an issue with v2.3.0
where our bundled components are now outputting [object Object]
class names because of this recent change to support a custom toString
fn.
The problem only occurs after we run our code through our build pipeline which uses Rollup/Babel to produce a CJS bundle so we can render server-side.
Component Code:
const inputStyleClass = classNames(styles['text_input__input'], {
[styles['text_input__input--with-icon']]: !!icon,
});
Transpiled code:
var inputStyleClass = classnames(
styles$z['text_input__input'],
(_classNames2 = {},
_defineProperty$2(_classNames2, styles$z['text_input__input--with-icon'], !!icon),
_classNames2,
)
);
We’ve locked our components to 2.2.6
to resolve the issue and suggest the following change:
if ((/\{\s*\[native code\]\s*\}/).test(arg.toString)) {
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
} else {
classes.push(arg.toString());
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Object - JavaScript - MDN Web Docs
Chrome Edge
Object Full support. Chrome1. Toggle history Full support. Edge12. Toggle hi...
Object() constructor Full support. Chrome1. Toggle history Full support. Edge12. Toggle hi...
assign...
Read more >9. Classes — Python 3.11.1 documentation
Creating a new class creates a new type of object, allowing new instances of that ... The namespace containing the built-in names is...
Read more >Python - Classes and Instances (__init__, __call__, etc.)
The return value will be the newly created object. In Python, there is no explicit new operator like there is in c++ or...
Read more >OpenAPI Specification - Version 2.0
Version 2.0 specification defines a set of files required to describe an API. These files can then be used by the Swagger-UI project...
Read more >Object Class (System)
Returns a string that represents the current object. Applies to. Product, Versions .NET, Core 1.0, Core 1.1, Core 2.0, Core ...
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
We’re experiencing this issue because we’re executing our render code in a Node VM, which means we actually have multiple Object globals in memory and the
toString
equality check fails. I managed to create a minimal reproduction: https://runkit.com/embed/3svylngmhh23@BrianAtIgloo could you verify if
!arg.hasOwnProperty('toString')
resolves your issue?