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.

Invalid CSS output from function based dynamic styles

See original GitHub issue

Current behavior:

Using an array of styles leads to invalid CSS properties in the DOM named label, name, and styles.

On the first style passed, the invalid CSS prop label does not appear in the DOM, but for subsequent styles it does. Additionally the first rule in the CSS in each style passed is nested invalidly like so: styles: color: red;

image

To reproduce:

Can’t reproduce this issue on CodeSandbox - so possibly related to babel or webpack would be my guess. Does the order of babel plugins matter when including the emotion plugin? I get this issue whether I use the plugin or not.

Expected behavior:

No invalid props in the DOM and the first rule is not mangled and ignored.

Environment information:

  • react version: 16.9.0
  • emotion version: 10.0.17

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:24 (21 by maintainers)

github_iconTop GitHub Comments

1reaction
Dajustcommented, Dec 11, 2020

Just encountered this problem while migrating from v9 to v11. Removing emotion from babel plugins fixed it for me as I already have @emotion/babel-preset-css-prop in babel presets.

1reaction
Andaristcommented, Oct 22, 2019

Unfortunately, nothing comes to my mind as to what we could do to warn about smth like this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make Your CSS Dynamic with CSS Custom Properties - Toptal
Explore CSS custom properties and find out how they can be used to make better, more dynamic stylesheets.
Read more >
How to set the CSS from Javascript of a dynamic data
The following code should work if a is the correct element (difference with your code being "style" instead of "styles" and encapsulating ...
Read more >
Enables functions for dynamic styles - JSS
If you want dynamic behavior for your Style Sheet, you can use functions as a value which return the actual value or a...
Read more >
A Complete Guide to CSS Functions
Like any other programming language, CSS has functions. They can be inserted where you'd place a value, or in some cases, ...
Read more >
Using CSS custom properties (variables) - MDN Web Docs
Each CSS property can be assigned a defined set of values. If you try to assign a value to a property that is...
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