Targeting another emotion component does not work.
See original GitHub issueCurrent behavior:
I am following the docs here in order to target another emotion component. Copying the example does not work as no child component styles are applied.
To reproduce:
https://codesandbox.io/s/emotion-issue-template-ll8py?file=/src/index.js
Expected behavior:
The child component should be green but it’s red.
Environment information:
react
version: react@16.13.1emotion
version: emotion@9.2.6
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Target another component on hover using emotion-js
Here is my code and what I have tried. import React from 'react'; import styled from '@emotion/styled'; import { Link } from 'gatsby';...
Read more >Styled Components - Emotion
styled is a way to create React components that have styles attached to them. It's available from @emotion/styled. ... Targeting another emotion component....
Read more >Style library interoperability - Material UI - MUI
If you are already using a custom theme with styled-components or Emotion, it might not be compatible with MUI's theme specification. If it's...
Read more >Why We're Breaking Up with CSS-in-JS - DEV Community
I'm using Emotion with server-side rendering and MUI/Mantine/(another Emotion-powered component library) and it's not working because.
Read more >The styled-components Happy Path - Josh W Comeau
styled-components is a wonderfully powerful styling library for React, ... Here's another way to solve the problem, using CSS variables:.
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
The Babel plugin would probably override the manual target - it literally inserts this target to the code, this is how component selectors are implemented. I’ve just dropped using the Macros because didn’t have time to figure out why they didn’t work on the codesandbox (and they should). So I’ve prepared an equivalent demo without a Babel plugin being used - but it contains very similar code to which Babel plugin transpiles styled components.
Ok, I’ve dropped using Babel Macros there as I hadn’t much time to figure out what’s wrong. I’ve prepared an equivalent demo though: https://codesandbox.io/s/emotion-issue-template-forked-odeq5?file=/src/index.js . What Babel plugin does is that it just inserts an option argument with a
target
property and this can be used manually with success. Can’t reproduce your problem with the project exploding - everything works fine, so you would have to prepare a repository with your issue reproduced so I could take a deeper look at your problem.