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.

universal render and css-modules

See original GitHub issue

Hey Claudio,

css-modules is a very good idea but it’s not working properly in isomorphic render. Server side does not recognise the following code:

import cx from 'classnames';
import styles from './styles.css';
...

class Header extends Component {
    render() {
        return (
            <h1 className={cx('m0', 'py2', 'h4', styles.siteName)} >
...

It seems that the server ignore the styles.siteName class.

Error Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server: (client) “/” class="m0 py2 h4 styles__site-name__ (server) “/” class=“m0 py2 h4” data-reactid=“15”>

I found a topic about this subject on Github https://github.com/css-modules/css-modules/issues/9#issue-86142149 also it seems to have found a solution https://github.com/css-modules/css-modules/issues/9#issuecomment-112373765

Maybe we can apply it in rfx-stack too.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alisamarcommented, Jul 28, 2016

@foxhound87 I figured out what went wrong, It looks like a camelCase issue. styles.siteName did not work but styles['site-name'] works just fine!

0reactions
foxhound87commented, Mar 10, 2017

You are not implementing the SSR in the right way, as you can read in the error, your render method is impure.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GitHub - colinmeinke/css-modules-universal-example
A spec that requires CSS class names to be scoped locally by default. This means that in each CSS file, we can have...
Read more >
CSS Modules — Solving the challenges of CSS at scale
With CSS Modules, you're free to name your classes whatever you like, without fear of global scope issues.
Read more >
CSS Modules and React
In this final post of our series on CSS Modules, I'll be taking a look at how to make a static React site...
Read more >
Styling Components In React - Smashing Magazine
CSS and SASS is universal and has no opinion on how you render ... When using CSS Modules, each React component is provided...
Read more >
CSS vs. CSS-in-JS: How and why to use each - LogRocket Blog
A CSS Module is a CSS file in which all the properties are scoped locally by default in the rendered CSS. JavaScript processes...
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