cssinjs/jss

Warning because of dynamic values during SSR

Open

#1277 opened on Feb 3, 2020

View on GitHub
 (24 comments) (11 reactions) (0 assignees)JavaScript (7,000 stars) (434 forks)batch import
bughelp wanted

Description

Describe the bug: I'm using my styles like these:

export default (theme) => ({
    root: {
        position: 'relative',
        display: 'inline-flex',
        alignItems: 'center',
        textAlign: 'center',
        background: theme.bgColor,
        fontWeight: ({weight}) => weight, // here is the problem
    },
});

And I'm getting this error on server-side (client is fine): Warning: [JSS] Rule is not linked. Missing sheet option "link: true". If I delete the dynamic value for fontWeight I will not get this error again. The problem not only in the warning itself, but also in the way how my styles will be applyed in production mode (they break styles in the styles where I'm using dynamic value and server sends me wrong styles after page reloading). P.S. I have tried using styles like this const useStyles = createUseStyles(styles, {link: true}); and it's still not working :(

Codesandbox link: I'm sorry, I have a problem with adding codesandbox.io with SSR and node.js console.

  • latest version:
  • Chrome:
  • Windows:

Contributor guide