Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scoped child Components opt-in #605

Closed
wants to merge 3 commits into from
Closed

Add scoped child Components opt-in #605

wants to merge 3 commits into from

Conversation

bySabi
Copy link

@bySabi bySabi commented Dec 5, 2019

This PR include @bernhardc 's work #574 plus some test and doc

I hope this is ok, be accepted and can be merge soon, before next v4 release.

I create repo example here https://github.com/bySabi/styled-jsx-repo for the intrepid people.

@bySabi
Copy link
Author

bySabi commented Dec 5, 2019

After experimenting a bit with the fork, I have concluded that this PR is not very useful.
The selector works only with the element of the child component that has the className.
I thought, fool of me, that applying a selector on the child's container would allow me to select each subelement using nesting &.

It seemed so easy :-(

So I don't think this PR has any value.

@masad-frost
Copy link

Honestly this is how I'd expect it to work

@masad-frost
Copy link

const Parent = () => {
  return (
    <div>
      <Child className="blah" />
      <styled jsx>{`
        div {
          color: red;
        }
        .blah {
          color: green;
        }
      `}</style>
    </div>
  )
}
const Child = ({ className }) => {
  return <div>
    <span className={className}>hello</span>
  </div>
}

I expect

<div class="jsx-123">
  <div>
    <span class="jsx-123 blah">hello</span>
  </div>
</div>

Not

<div class="jsx-123">
  <div class="jsx-123">
    <span class="jsx-123 blah"></span>
  </div>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants