React-admin: Huge Icons and Messed Up CSS After Building and Deploying

Created on 18 Jan 2019  路  10Comments  路  Source: marmelab/react-admin

What you were expecting:

This app is a full stack PERN app (pgsql, express, react, node). After building and logging into the app, everything looks fine.
screen shot 2019-01-17 at 3 01 20 pm

What happened instead:

Upon any subsequent reload, whether it's going to the url or hitting refresh, this happens. The icons get huge and all the styling gets busted.
screen shot 2019-01-17 at 3 01 32 pm

Steps to reproduce:

Build a full PERN stack app, build, and deploy it.

Environment

  • React-admin version: "^2.6.0"
  • React version: "^16.6.0"
  • Browser: Chrome

Most helpful comment

https://material-ui.com/customization/css-in-js/#creategenerateclassname-options-class-name-generator @jbeurel in the examples of this link

Sorry was on the road, hard to paste the code

Here it is

import JssProvider from 'react-jss/lib/JssProvider';
import { createGenerateClassName } from '@material-ui/core/styles';

const generateClassName = createGenerateClassName({
  dangerouslyUseGlobalCSS: true,
  productionPrefix: 'c',
});

function App() {
  return (
    <JssProvider generateClassName={generateClassName}>
      ...
    </JssProvider>
  );
}

export default App;

All 10 comments

Hi, and thanks for reporting the issue.

We can't replicate it (see https://marmelab.com/react-admin-demo/, which is developped with react-admin 2.6, built, and deployed on a CDN). Without further details about your problem (console errors, CodeSandbox), we won't be able to fix it. Can you please help us reproduce your issue?

Hello,

There was some dependency differences between our project and your demo. I matched the dependencies to be identical to the demo and also removed all dependencies that may have Materialize in them which included react google login. After that, the page is rendering correctly.

Thank you for your response,
Jon

Something similar is happening to me after building.
The admin interface seems broken, see:

screenshot 2019-01-25 09 12 57

I need to logout and login in order for things to work properly.

@edgardz Please double check your dependencies versions (especially material-ui core and icons). If still reproduce this issue then please provide a codesandbox to help debugging it

Yeah!
After downgrading material-ui to the versions below, it is now working great.

"@material-ui/core": "~1.4.0",
"@material-ui/icons": "~1.1.0",

Thank you very much @djhi

I've the same red text color and big icons bug.

capture d ecran 2019-01-31 a 22 39 46

I fix the version like @edgardz but that does not change anything.

"dependencies": {
    "@api-platform/admin": "^0.6.2",
    "@material-ui/core": "~1.4.0",
    "@material-ui/icons": "~1.1.0",
    "auth0-js": "^9.10.0",
    "connected-react-router": "^4.5.0",
    "foreman": "^3.0.1",
    "graphql": "^14.1.1",
    "history": "^4.7.2",
    "jwt-decode": "^2.2.0",
    "normalizr": "^3.3.0",
    "react": "^16.7.0",
    "react-admin": "^2.6.3",
    "react-dom": "^16.7.0",
    "react-intl": "^2.8.0",
    "react-redux": "^5.0.7",
    "react-relay": "^1.7.0",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "react-scripts": "^2.1.3",
    "redux": "^4.0.1",
    "redux-form": "^8.1.0",
    "redux-persist": "^5.10.0",
    "redux-saga": "^0.16.1",
    "relay-compiler": "^1.7.0",
    "relay-runtime": "^1.7.0",
    "reselect": "^4.0.0",
    "save-dev": "^2.0.0",
    "styled-components": "^3.4.9",
    "superagent": "^4.1.0"
  },

@jbeurel i have the same issue, did you resolve it?

for anyone here, it is due to conflict of classnames stated in this thread https://github.com/mui-org/material-ui/issues/8223, and i use generateClassName from @material-ui/core/styles to add a prefix

Hi @roychoo Could you copy/paste some code example of your workaround?

https://material-ui.com/customization/css-in-js/#creategenerateclassname-options-class-name-generator @jbeurel in the examples of this link

Sorry was on the road, hard to paste the code

Here it is

import JssProvider from 'react-jss/lib/JssProvider';
import { createGenerateClassName } from '@material-ui/core/styles';

const generateClassName = createGenerateClassName({
  dangerouslyUseGlobalCSS: true,
  productionPrefix: 'c',
});

function App() {
  return (
    <JssProvider generateClassName={generateClassName}>
      ...
    </JssProvider>
  );
}

export default App;
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ilaif picture ilaif  路  3Comments

kdabir picture kdabir  路  3Comments

waynebloss picture waynebloss  路  3Comments

Dragomir-Ivanov picture Dragomir-Ivanov  路  3Comments

yangjiamu picture yangjiamu  路  3Comments