Duplicate generated css classname
See original GitHub issueTwo styled components have same css rule will have same generated css class name. It’s OK for production. But when we develop website if we modify one css class rule by using dev tool. The changed is affect to other component too.
Are styled component have same class by design to reduce output css?
Version
1.0.5
Steps to reproduce
const HeaderContent = styled.div`
max-width: 1280px;
`
const FooterContent = styled.div`
max-width: 1280px;
`
Expected Behavior
HeaderContent and FooterContent have different generated class name
Actual Behavior
HeaderContent and FooterContent have same generated class name
output class name: dqUvXD
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Micro-frontends: Fixing duplicate class name in Styled ...
Solution 2: wrap micro frontend to scope. css can be scoped by adding custom parent selector, and wrapping your micro app inside div...
Read more >Use duplicate class name on an element? - Stack Overflow
I found that there are many frameworks will check the duplicate class name before adding the new class name on the element that...
Read more >Specificity - CSS: Cascading Style Sheets - MDN Web Docs
As a special case for increasing specificity, you can duplicate weights from the CLASS or ID columns. Duplicating id, class, pseudo-class or ...
Read more >Sass: @extend
Unlike mixins, which copy styles into the current style rule, @extend updates style ... aside .notice dd { // Sass doesn't generate CSS...
Read more >[MPP] Duplicate JVM class name generated from - YouTrack
After declaring extension functions in the same file as the expect class, build failed with Duplicate JVM class name. expect class BleConnection {}....
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 FreeTop 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
Top GitHub Comments
Yes, this is working as intended I think? /cc @geelen
We generate the class name based on a hash of the contents of the class.
@nhducit If you want to just modify one in the dev tools, you can adjust it in the element.style pane when inspecting and it will only adjust that particular element.
I would imagine this is how we would always want it to work following most modern approaches to CSS. If they both have the same styles I would give them the same class and modify them if they diverge. Without generated class names, I would name them with a class that describes them both.