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.

[V.2.0.1] Parent inheritance problem

See original GitHub issue

Please check this: https://codesandbox.io/s/wplNXEN1J Check .modifier & { underneath.

This JSX:

<Container>
  <div className='modifier'>
    <div className='wrapper'>Hello World, this is my first styled component!</div>
  </Container>
</div>

const Container = styled.div`
  .wrapper {
    background-color: green;
    .modifier & {
      background-color: red;
    }
  }
`;

Renders this HTML:

<div class="sc-bdVaJa YJEIW">
  <div class="modifier">
    <div class="wrapper">Hello World, this is my first styled component!</div>
  </div>
</div>

The CSS is compiled as:

.sc-bdVaJa {}
.YJEIW .wrapper{background-color: green;}
.wrapper .modifier .YJEIW{background-color: red;}

I think the modifier should be: .YJEIW .modifier .wrapper

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ehtbcommented, Jun 11, 2017

Hi @philpl It is only to illustrate the issue, not to be a real world example.

0reactions
ehtbcommented, Jun 12, 2017

@thysultan Great, thanks for the fast fix!

@philpl Just did, can confirm that 2.0.1 with stylis 3.1.6 works. Awesome work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Child inheritance generating InvalidCastException #10446
Issue I am trying to use Table Per Hierarchy inheritance in conjunction with a one to many relationship. Both the Parent and child...
Read more >
Avoid wrong version interpolation if child's pom version is ...
There is another pom which declares the parent pom as its parent too (inheritance) but is not listed as sub module in this...
Read more >
Analysis on Inheritance in Open Source Systems
When referring to an item that is being inherited by another, the words superclass, parent, and ancestor may be used. The term type...
Read more >
Thinking in Java, 3rd ed. Revision 2.0: 1: Introduction to Objects
This is effectively what you get with inheritance, with the exception that if the original class (called the base or super or parent...
Read more >
What Programmers do with Inheritance in Java
However, some compilers will write P#parent into the bytecode. As this information is not used in method lookup, the difference does not cause...
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