question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate generated css classname

See original GitHub issue

Two 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:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
mxstbrcommented, Nov 7, 2016

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.

1reaction
bhoughcommented, Nov 7, 2016

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found