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

Styles for referenced component with props are not applied #488

Open
uc-artur opened this issue Sep 15, 2022 · 0 comments
Open

Styles for referenced component with props are not applied #488

uc-artur opened this issue Sep 15, 2022 · 0 comments

Comments

@uc-artur
Copy link

Hi!

I tried to reference a component with props to add/overwrite some values but it only works if the referenced component has no props, with props the style is not applied consistently. I expected all wrapped components to have lightgreen background with a border, but that is not the case:

const ComponentWithProps = styled("div")`
  width: ${({w}) => (w || 100)}px;
  background: lightgrey;
`;

const WrapperWithReference = styled("div")`
  ${ComponentWithProps} {
    background: lightgreen;
    border: 1px solid black;
  }
`;

const App = () => {
  return (
    <WrapperWithReference>
      <ComponentWithProps w={100}>expecting lightgreen bg with border</ComponentWithProps>
      <ComponentWithProps w={110}>expecting lightgreen bg with border</ComponentWithProps>
    </WrapperWithReference>
  );
};

https://codesandbox.io/s/silent-lake-is6e2g?file=/src/App.js

Am I missing something?

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

No branches or pull requests

1 participant