Migration to Material-ui V4

回眸只為那壹抹淺笑 提交于 2019-12-11 05:04:08

问题


When I go to migrate material-ui from version 3.9.3 to version 4.3.2 in my React Application, I get an error like TypeError: styles_1.createGenerateClassName is not a function.

I'm completely confused on how to migrate to Material UI V4. What are the necessary packages I need with the correct version?

If any one has worked on this kind of scenario, please help me.

Thanks.

This is my package.json file:

"dependencies": {
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "@date-io/moment": "^1.3.1",
    "@material-ui/core": "4.3.0",
    "@material-ui/icons": "4.2.1",
    "@material-ui/styles": "4.3.0",
}

回答1:


In v3, createGenerateClassName came from @material-ui/core:

import { createGenerateClassName } from '@material-ui/core/styles';

In v4, that comes from the dependency @material-ui/styles:

import { createGenerateClassName } from '@material-ui/styles';

For further migration, see: https://material-ui.com/guides/migration-v3/



来源:https://stackoverflow.com/questions/57577181/migration-to-material-ui-v4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!