Component selectors can only be used in conjunction
See original GitHub issueHello following the docs to use the styled, but I got the following error:
Component selectors can only be used in conjunction with babel-plugin-emotion
code:
import styled from '@emotion/styled';
import { flexCenter, mxw80, flex, flexAlignCenter } from '../../globals/flex';
export const IconContainer = styled.div``;
export const SearchContainer = styled.div`
display: inline-flex;
align-items: center;
flex: 0 1 350px;
border: 1px solid #ccc;
border-radius: 25px;
overflow: hidden;
height: 55px;
background: white;
${IconContainer} {
${flexAlignCenter}
width: 50px;
padding: 0.5rem;
height: 100%;
}
& > input {
width: calc(100% - 50px);
height: 100%;
border: 0;
padding: 0.5rem 0.5rem 0.5rem 0;
outline: none;
}
`;
jsx:
<SearchContainer>
<IconContainer>
<FontAwesomeIcon
className="searchIcon"
icon={faSearch}
size="lg"
fixedWidth
color="#1976d2"
/>
</IconContainer>
<input></input>
</SearchContainer>
.babelrc:
{
"plugins": [
[
"emotion",
{
// sourceMap is on by default but source maps are dead code eliminated in production
"sourceMap": true,
"autoLabel": process.env.NODE_ENV !== "production",
"labelFormat": "[local]",
"cssPropOptimization": true
}
]
],
"presets": [
[
"@emotion/babel-preset-css-prop",
{
"autoLabel": true,
"labelFormat": "[local]"
}
]
]
}
I looked for this error and found no solution
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Component selectors can only be used in conjunction with ...
Component selectors can only be used in conjunction with @emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware compiler transform. Seeing the ...
Read more >Component selectors can only be used in conjunction with ...
Component selectors can only be used in conjunction with babel-plugin-emotion error while using emotion · Ask Question. Asked 2 years, 8 months ...
Read more >Component selectors can only be used in conjunction with ...
Coding example for the question Component selectors can only be used in conjunction with babel-plugin-emotion error while using emotion-Reactjs.
Read more >emotion/babel-plugin
Allows an emotion component to be used as a CSS selector. Minification, ✓, Any leading/trailing space between properties in your css and styled...
Read more >[Next.js] Component selectors can only be used in conjunction ...
[Next.js] Component selectors can only be used in conjunction 이슈 · body · div · p · div ...
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
This codesandbox is using Create React App template and you can’t customize babel plugins with that. This is, by design, not allowed when using CRA.
However they support Babel macros and we provide one, so if you make this change:
This starts to work as expected.
using
@emotion/styled/macro
throws me the following eslint error: