Component selectors not working with `@emotion/babel-preset-css-prop`
See original GitHub issue@emotion/core
version:^10.0.10
@emotion/styled
version:^10.0.11
@emotion/babel-preset-css-prop
version:^10.0.9
react
version:^16.8.4
Relevant code:
import styled from "@emotion/styled";
export const Text = styled.div`
opacity: 1;
`;
export const Main = styled.div`
${Text} {
color: red;
}
`;
What you did: First off, thank you all for your tireless work on the emotion library. It’s an excellent set of packages!
In trying to complete the upgrade to emotion v10 in a private codebase. I’m mostly there except for one key issue that I’ve run into. Namely, component selectors don’t seem to be supported when using @emotion/babel-preset-css-prop
.
It may be relevant to include that I’m also working in a TypeScript project.
What happened: Error is thrown. Error message reads:
Uncaught Error: Component selectors can only be used in conjunction with babel-plugin-emotion.
This is an unexpected error because I am using @emotion/babel-preset-css-prop
which already uses babel-plugin-emotion
under the hood.
Reproduction: Link to repro
Suggested solution: Not familiar enough with emotion codebase to recommend a solution but happy to take a crack at it.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:10 (3 by maintainers)
Top GitHub Comments
Yes, that’s the most probable problem - there is an open PR which will help you once it gets merged in: https://github.com/emotion-js/emotion/pull/1220 . There is not ETA for this yet though.
Closing this right now - because the mentioned #1220 is supposed to fix this and I will be working this month to land this. It will be a part of the upcoming v11 release.