Comments (1)
I'm also experiencing this issue, however, the classes get generated when there is whitespace after the styleName attribute.
This JSX code...
<ul className="justify-content-center" styleName="pagination">
<li styleName={`page-item${isFirstPage ? " disabled" : ""}`}>
<a styleName="page-link" href={`${basePath}/1`} aria-label="First">
<span aria-hidden="true">«</span>
<span className="sr-only">First</span>
</a>
</li>
</ul>
... produces this DOM structure.
<ul class="justify-content-center ">
<li class="">
<a class="" href="/blog/posts/1" aria-label="First">
<span aria-hidden="true">«</span>
<span class="sr-only">First</span>
</a>
</li>
</ul>
However, when I put a space after the first styleName
attribute only...
<ul className="justify-content-center" styleName="pagination" >{/* Note the space before the closing angle bracket*/}
<li styleName={`page-item${isFirstPage ? " disabled" : ""}`}>
<a styleName="page-link" href={`${basePath}/1`} aria-label="First">
<span aria-hidden="true">«</span>
<span className="sr-only">First</span>
</a>
</li>
</ul>
all styleName
s generate their corresponding className
s.
<ul class="justify-content-center pagination___3ieNK">
<li class="page-item___2eMHw disabled___2y7aB">
<a class="page-link___t-Mvf" href="/blog/posts/1" aria-label="First">
<span aria-hidden="true">«</span>
<span class="sr-only">First</span>
</a>
</li>
</ul>
In another instance, the styleName
attribute was not able to be converted over because there wasn't a space before a self-closing <img>
tag. (i.e. <img src="..."/>
vs. <img src="..." />
) Adding the space before self-closing the tag enabled the styleName
to generate the className
.
Edit: A temporary workaround for the issue I'm having is to position the styleName
attribute such that it isn't the last one in the DOM element. This ensures that there is a space after the attribute. This will not work if the styleName
is the only attribute in the element.
from babel-plugin-react-css-modules.
Related Issues (20)
- Whenever I use babel-plugin-react-css-modules, I get errors from babel-loader
- in production after bundle ,class name in css file not equal to it in html tags,very confusing .when styleName = 'className' appear this error but write className = {style.className} is disappear
- handleMissingStyleName and Runtime styleName
- set skip true, and current sub component no stylesheet, stylesheet from parent of parent less and output fail
- styleName compiled to stylename (lowercase)
- Not compatible with css-loader v4 HOT 28
- Typescript: styleName usage with @types/react@^17 HOT 4
- Upgrade postcss to 8 HOT 3
- setting attributeNames to "className": "className" will not output any classnames HOT 1
- Can I use webpack resolve.extensions = [".css"] and use import './table' instead of './table.css' in js HOT 1
- Plugin does't work after updating react-scripts to version 4.3.0 HOT 1
- [contenthash] generated by this plugin does not match the hash generated by css-loader 5.2.0 HOT 3
- Current master branch does not pass all tests HOT 7
- Temporary fix for those have trouble with newer version of webpack / css-loader. HOT 7
- How to pass styles from component to child and grandchild at the same time
- Passing multiple style props to a child component HOT 1
- doesn't work with windicss
- doesn't work with thread-loader
- babel-plugin-react-css-modules doesn't recognize the @ path
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-react-css-modules.