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.

Some css styles are not created in production but work in development

See original GitHub issue

Hello,

We are hitting an odd css/emotion issue in production, while the component works great in development. We’ve tried this on v2.0.0-v.2.2.0 and its the same issue with all of them.

The dynamic css rules for the outer divs never get created in the emotion stylesheet. They are, however, set on the divs in the DOM. The rest of the dynamic css rules (e.g. on the options when you click on the control) do get created in the emotion stylesheet. This only happens on a few pages in our app, while other parts work as expected. Here is a screenshot of the the DOM when the page loads.

screenshot from 2019-01-01 19-22-05

You’ll notice that the select outermost div was assigned a classname of css-10nd86i, but that css rule does not actually exist in the DOM. Using the javascript console to dump out the emotion stylesheet, you’ll notice in this screenshot that the rules are totally empty in the stylesheet.

screenshot from 2019-01-01 19-23-24

Now if you click on the select control to open it, the css rules for the options list all get created:

screenshot from 2019-01-01 19-43-12

So the options get styled correctly, but the primary select component does not. I’ve tried various versions of emotion, react-select, react, etc., but the issue still persists. We’ve had to swap out this component in production for the time being, but would like to figure this out. Any help would be greatly appreciated.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:13
  • Comments:39 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
wegrycommented, Mar 5, 2021

This seems like it’s still present in react-select@4.2.1.

5reactions
NearHuscarlcommented, Aug 23, 2020

I managed to fix the issue by adding classNamePrefix which seems to force react-select to add the classNames to the sub-components in production

<Select
  classNamePrefix='select'
  {...}
/>

Before

<div class=" css-1hwfws3">
  ...
</div>

After

<div class="select__value-container select__value-container--is-multi select__value-container--has-value css-1hwfws3">
  ...
</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack 5 - some styles are missing in production but exist in ...
seems like the build hash of your two main.<hash>.css files are different. Could you check whether it might be a caching problem or...
Read more >
CSS on production not working [solved] - Laracasts
When I push my project to my production server none of the css is being applied. I am look. ... All pages work...
Read more >
CSS not working in production - MSDN - Microsoft
I have a website which was developed using .Net Framework 3.5 and all the CSS is spot on. However, when I publish the...
Read more >
Solving the React Error: Not Picking Up CSS Style | Pluralsight
CSS helps in styling webpages, but sometimes code may not get properly imported or may show a few errors while it is being...
Read more >
Cascade, specificity, and inheritance - Learn web development
At some point, you will be working on a project and you will find that the CSS you thought should be applied to...
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