react-scoped-css icon indicating copy to clipboard operation
react-scoped-css copied to clipboard

Doesn't work with React.createElement

Open oqx opened this issue 4 years ago • 5 comments

Hey -- great package. That said, any plans to allow this to work with createElement?

When using createElement, it does add a hashed attribute, however, it doesn't correspond to the one attached to the class in the generated CSS.

oqx avatar Sep 11 '19 22:09 oqx

Current implementation will only add data-v hash to jsx element. To enable the use of React.createElement, more work needs to be done. I have a couple of ideas upon that, but none is good enough.

Can you provide a simple code example or a mini repo? if it did add hash to createElement, it could be a bug.

gaoxiaoliangz avatar Sep 12 '19 02:09 gaoxiaoliangz

I'll see if I can whip up a repo once I'm on my home machine. Thanks!

oqx avatar Sep 12 '19 21:09 oqx

Any update on getting this to work? It would be great to have for use with dynamically created components.

dhkatz avatar Feb 11 '20 20:02 dhkatz

I have the same appeal.

hwaphon avatar Apr 01 '21 03:04 hwaphon

Hi, I have a reproducible example of this issue. I use react-markdown for content on my site, which under the hood uses React.createElement and React.Fragment to render components by default as seen in their source code. It also uses React.createElement further down

Here's a link to the relevant code in my project.

For what it's worth - my FlexibleLink component properly applies styles specificed in FlexibleLink.scoped.scss (imported into FlexibleLink.ts). And the custom component CodeBlock properly applies styles specified in MarkdownRenderer.scoped.scss - I believe this is expected, as react-scoped-css can see the JSX element when parsing the MarkdownRenderer file to apply styles.

Sorry if this isn't much help - just stumbled upon this and fortunately had a repro example handy

alex-a-pereira avatar Dec 17 '22 17:12 alex-a-pereira