Production build issue when attribute selectors are used with @emotion/styled approach
See original GitHub issueCurrent behavior:
Attribute selector doesn’t work in production build when the styled approach is used. Currently, it can be solved by using css`` approach instead.
To reproduce:
- Create an empty react CRA project
- Use the following styled component styles:
const ComponentStyled = styled.div`
&[data-placement*='top'] .nested-element-selector {
<any rules here>
}
`;
Expected behavior:
CSS styles should be applied for production build, but it is working only in dev.
Environment information:
react
version: 17.0.1@emotion/react
version: 11.1.4@emotion/styled
version: 11.0.0@emotion/css
version: 11.1.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Styled-components vs. Emotion for handling CSS
Explore the benefits, drawbacks, and differences between two CSS-in-JS libraries: styled-components and Emotion-JS.
Read more >How To Use Emotion for Styling in React | DigitalOcean
Learn how to style components in React using the emotion CSS-in-JS library.
Read more >Attribute selectors - CSS: Cascading Style Sheets | MDN
It is often used for language subcode matches. [attr^=value]. Represents elements with an attribute name of attr whose value is prefixed ( ...
Read more >The css Prop - Emotion
Babel Preset. This method will not work with Create React App or other projects that do not allow custom Babel configurations. Use the...
Read more >Quick Introduction to Styling React Components with Emotion
In React, we can use inline styling using the style property that is available for all components. There are drawbacks to this approach...
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
Any news on that? Seems like selector are still not usable in production.
@avmalyutin thank you for the repro case - it was really helpful and I’ve prepared a fix for this issue based on it: https://github.com/emotion-js/emotion/pull/2283