迁移到Material-ui V4 [英] Migration to Material-ui V4
问题描述
当我在React Application中将material-ui从3.9.3版本迁移到4.3.2版本时,出现类似以下错误 TypeError:styles_1.createGenerateClassName不是函数.
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.
我对如何迁移到Material UI V4感到完全困惑.正确版本需要什么必要的软件包?
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.
谢谢.
这是我的package.json文件:
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",
}
推荐答案
在v3中,createGenerateClassName
来自@material-ui/core
:
import { createGenerateClassName } from '@material-ui/core/styles';
在v4中,它来自依赖项@material-ui/styles
:
In v4, that comes from the dependency @material-ui/styles
:
import { createGenerateClassName } from '@material-ui/styles';
有关进一步的迁移,请参阅: https://material-ui.com/guides/migration-v3/
For further migration, see: https://material-ui.com/guides/migration-v3/
这篇关于迁移到Material-ui V4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!