小编Kru*_*hah的帖子

MUI v5 迁移 - 用样式实用程序替换 withStyles 和 createStyles

我正在尝试将我的 MUI v4 迁移到 v5

尝试替换所有这些实用程序,例如 withStyles、createStyles 和 makeStyles

我现有的代码如下:

export const DrawerThumbnail = withStyles(() =>
  createStyles({
    drawerPaper: {
      width: '200px',
      top: 112,
      backgroundColor: Color.White,
      border: 'none',
      marginTop: '2px',
      padding: '0px 5px 0px 5px',
    },
  })
)(({ classes, ...props }: any) => {
  return (
    <Drawer
      variant="permanent"
      classes={{
        paper: classes.drawerPaper,
      }}
      anchor="left"
      {...props}
    />
  );
});
Run Code Online (Sandbox Code Playgroud)

尝试使用@mui/system 中的样式实用程序新代码看起来像这样,但显然它不起作用,因为我不知道如何使用样式实用程序转换上述内容。

export const DrawerThumbnail2 = styled((props: any) =>
    <Drawer
      variant="permanent"
      anchor="left"
      {...props}
    />
  )`
      width: '200px';
      top: 112;
      background-color: ${Color.White};
      border: 'none';
      margin-top: …
Run Code Online (Sandbox Code Playgroud)

migration material-ui

7
推荐指数
0
解决办法
584
查看次数

标签 统计

material-ui ×1

migration ×1