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

`createElement` and `cloneElement`

Offen
#181 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
2k
Forks
159
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginnen Sie damit, die Behandlung von styleName durch das Plugin und die vorhandenen Tests für JSX-Transformationen zu finden. Untersuchen Sie, wie React.createElement und React.cloneElement Props erhalten, und definieren Sie anschließend Tests, die zeigen, dass beide APIs styleName transformieren, ohne es auf dem DOM-Element zu belassen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
babel, javascript, react
Bereich
frontend, tooling
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.