cssinjs/jss

Warning because of dynamic values during SSR

Open

#1,277 创建于 2020年2月3日

在 GitHub 查看
 (24 评论) (11 反应) (0 负责人)JavaScript (7,000 star) (434 fork)batch import
bughelp wanted

描述

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:

贡献者指南