Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class "displayName" that styled-components offer, does not get applied if MUI is used #33565

Closed
2 tasks done
TurkaljGoran opened this issue Jul 18, 2022 · 3 comments
Closed
2 tasks done
Assignees
Labels
package: styled-engine-sc Specific to styled-components status: waiting for author Issue with insufficient information

Comments

@TurkaljGoran
Copy link

TurkaljGoran commented Jul 18, 2022

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

I am using Next JS 12.2.2, it has SWC which now supports styled-components.
Material UI is the latest version.
styled-components is the latest version.

EXAMPLE 1: styled is used from styled-components:

import styled from "styled-components";

export const SCHeroTitle = styled("h2")`

color: pink;
background-color: blue;

`;

This will render correct displayName for the class:

image

Example 2: using styled from MUI

import {styled} from "@mui/material" or import {styled} from "@mui/material/styles" makes no difference.

export const SCHeroTitle = styled("h2")`

color: green;
background-color: grey;

`;

This will render a generic class name:

image

next.config.js has "compiler" object set with only this options for the purpose of testing if it works:

image

Same thing happens if I use Babel instead of SWC so thats not the issue, I was wondering is this intended by MUI - does it do something that prevents displayName to actually get applied and produce sensible class names or is this a bug?

Cheers guys!

Expected behavior 🤔

Class names with displayName applied.

Steps to reproduce 🕹

Steps:

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@TurkaljGoran TurkaljGoran added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 18, 2022
@creestor
Copy link

This is not working, because under the hood, mui used emotion.js for making styled components this entails that plugin for styled-components in swc is not compatible with emotion. Also i saw the issue about that here before, cause i have had the same problem.

@mnajdova
Copy link
Member

@TurkaljGoran are you using @mui/styled-engine-sc and configured it with an alias? Can you maybe share a simple reproduction repository?

@mnajdova mnajdova added status: waiting for author Issue with insufficient information package: styled-engine-sc Specific to styled-components and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Aug 22, 2022
@github-actions
Copy link

Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: styled-engine-sc Specific to styled-components status: waiting for author Issue with insufficient information
Projects
None yet
Development

No branches or pull requests

3 participants