Material-ui: Warning: Material-UI: You can only instantiate one class name generator on the client side.

Created on 24 Sep 2017  路  6Comments  路  Source: mui-org/material-ui

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

No warnings

Current Behavior

There is a warning

Steps to Reproduce (for bugs)

  1. Use a JssProvider

Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | v1.0.0-beta.12 |
| React | all |
| browser | all |

bug 馃悰

All 6 comments

The fix should be simple, increasing the threshold from 1 to 2.

Well, no, this fix doesn't work with HMR.

With this change and increasing the threshold to 2, it seems to be good :).

+import createGenerateClassName from 'material-ui/styles/createGenerateClassName';

+const generateClassName = createGenerateClassName()

    render() {
      return (
        <JssProvider
          registry={context.sheetsRegistry}
          jss={context.jss}
+         generateClassName={generateClassName}
        >

So now, I'm gonna wait users feedback and see if they want to go with this solution or we revert: #8341.

I'm getting this warning too.

Adding a generateClassName in the JSS Provider every time seems cumbersome. (well especially since I'm not sure what that does and I won't be using it :) )

@nicolasgarnier Alright, I'm gonna remove this warning in dev and only keep it for the production env 馃憤

I got this warning message on "material-ui": "1.0.0-beta.13" (with jss, jss-preset-default, react-jss: "lastest")
but after downgrade these packages, it's gone.

    "jss": "^8.1.0",
    "jss-preset-default": "^3.0.0",
    "react-jss": "^7.2.0",
Was this page helpful?
0 / 5 - 0 ratings