gajus / gajus/babel-plugin-react-css-modules

`createElement` and `cloneElement`

Open
#181 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2k
Forks
159
PR merge metrics
No merged PRs in 30d

Description

There is currently no support for using `createElement` and `cloneElement` with the `styleName` attribute (as far as I've tried), which at times can be a bit painful.

```jsx
render() {
const element = ordered ? 'ol' : 'ul';

return React.createElement(
element,
{
styleName: 'example-style', // <-- This
},
);
}
```

-->

```
Warning: React does not recognize the `styleName` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `stylename` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
```

I haven't read through the source code but t would assume it is a transform thing, where the `styleName` prop is not read as it's not a JSX prop but rather a passed in as an object. JSX gets transformed into `createElement`s so I would've guessed that this would work automatically but I guess not, unless I'm doing something wrong here.

Wondering if there's any ability for future support?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.