question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[styles] className contains invalid characters

See original GitHub issue
  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 🤔

CSS classes should not contains these characters i.e /()

Current Behavior 😯

Class name generated by the @material-ui/styles/styled contains some invalid characters i.e () which are attached to the DOM element. Screenshot from 2019-04-30 13-06-46

Steps to Reproduce 🕹

Just use this component

import React, { memo } from "react";
import Paper from "@material-ui/core/Paper";
import styled from "@material-ui/styles/styled";

const MyPaper = styled(Paper)({
    padding: "12px 24px"
});

const Surface = ({ children, ...props }) => (
    <MyPaper {...props}>{children}</MyPaper>
);

export default memo(Surface);

Your Environment 🌎

Tech Version
Material-UI 4.0.0-beta.0
Material-UI Styles 4.0.0-beta.0
React 16.8.6
Browser Chromium: 74.0.3729.108

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
oliviertassinaricommented, Apr 30, 2019

+90% of the people are using v3 that has this old regexp logic. Let’s have more people transition to v4, see how they respond. My intuition tells me we should revert, but I can be wrong. It’s better to run this experimentation and learn from it🔬:). Let’s wait.

1reaction
WitoTVcommented, Mar 5, 2021

@oliviertassinari Here, a little demo https://codesandbox.io/s/kind-silence-k60fe

Based on what I was able to figure out is that Swiper is trying to find elements but when it is trying to search for a class .Swiper-slide-4.WithStyles(Swiper)-slide-1 but that is not even a valid selector, that is why it’s “crashing”. I tried checking it with document.querySelector

UPDATE: I kind of resolved my issue, I moved all my styling from withStyles into makeStyles.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[styles] className contains invalid characters #15529 - GitHub
Class name generated by the @material-ui/styles/styled contains some invalid characters i.e () which are attached to the DOM element.
Read more >
Which characters are valid in CSS class names/selectors?
In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-z0-9] and ISO 10646 characters U ...
Read more >
Which characters are valid in CSS class ... - Includehelp.com
Here, we are going to learn which characters are valid in CSS class names/selectors?
Read more >
Which characters are valid in CSS class names/selectors?
A valid name should start with an underscore (_), a hyphen (-) or a letter (a-z)/(A-Z) which is followed by any numbers, hyphens,...
Read more >
CSS Quick Tip: The Valid Characters in a Custom CSS Selector
A valid name should start with an underscore (_), a hyphen (-) or a letter (a-z) which is followed by any numbers, hyphens,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found