Class name labels not added when using a re-exported version of the styled function
See original GitHub issueCurrent behavior:
babel-plugin-emotion
doesn’t add a class name label when using a re-exported version to the styled
function.
To reproduce:
https://codesandbox.io/s/emotion-issue-template-r8v3h
- Import
styled
from@emotion/styled
and re-export it. - Import the re-exported
styled
in your app and use it to create a component - Notice how the class name generated by
babel-plugin-emotion
does not include the variable name.
Description | Screenshot |
---|---|
Using styled directly from @emotion/styled . Notice -Title is appended to the class name of the <h1> . |
|
Using a re-exported version of styled . Notice -Title is missing from the class name of the <h1> . |
Expected behavior:
babel-plugin-emotion
should add the appropriate label to class names when using a re-exported version of the styled
function. I’m currently using a re-exported version of styled
in order to add the correct TypeScript types to the function, as instructed in the documentation.
Environment information:
react
version: 16.12.0@emotion/core
version: 10.0.22@emotion/styled
version: 10.0.23babel-plugin-emotion
version: 10.0.23
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Debug class names do not work when styled function ... - GitHub
When importing styled and using it in the same file, debug class names work as expected. // main.js import styled from "styled-components/macro" ...
Read more >re export styled from styled components macro not working
I tried with export { css, createGlobalStyle, keyframes, ThemeProvider, withTheme, styled } . But without success. import React from 'react'; ...
Read more >How To Use React Styled Components Efficiently - Copycat
Learn how to set up organized React styled components in your project through examples, comprehensive explanations, and tips and tricks!
Read more >Benefits of using styled-components in React - LogRocket Blog
With styled -components, the UI design's focus shifts from merely styling HTML elements or React components through className to defining ...
Read more >API Reference - styled-components
You can pass an arbitrary classname to a styled component without problem ... This is a method that creates a new StyledComponent with...
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
Closing this because, as mentioned, this will be resolved in v11 - but with it, there will also be fewer use cases for re-exporting styled. So, in general, it should become less of a pain to work with. Stay tuned.
This is a known issue and it has been fixed in v11 (available on npm under
next
tag). Unfortunately, it’s too complicated to backport this to v10 - but hopefully we should be able to ship v11 in a month (I encourage you to try it out today though, it’s stable and doesn’t include many breaking changes).Additionally - with v11 you shouldn’t have to reexport styled just to add Theme type. Instead, you will be able to augment builtin interface