持久抽屉不适用于 material-ui v5
Posted
技术标签:
【中文标题】持久抽屉不适用于 material-ui v5【英文标题】:Persistent Drawer not working with material-ui v5 【发布时间】:2021-10-20 11:34:10 【问题描述】:我正在尝试文档https://next.material-ui.com/components/drawers/#persistent-drawer 中的持久抽屉示例,但它没有编译。
/Users/alex/Dev/wnav-react2/src/App.tsx
TypeScript error in /Users/alex/Dev/wnav-react2/src/App.tsx(24,15):
Property 'open' does not exist on type ' theme?: Theme | undefined; as?: ElementType<any> | undefined; sx?: SxProps<Theme> | undefined; & ClassAttributes<htmlElement> & HTMLAttributes<...> & ...; '. TS2339
22 |
23 | const Main = styled('main', shouldForwardProp: (prop) => prop !== 'open' )(
> 24 | ( theme, open ) => (
| ^
25 | flexGrow: 1,
26 | padding: theme.spacing(3),
27 | transition: theme.transitions.create('margin',
任何线索可能是什么错误?
package.json:
"@emotion/react": "^11.4.1",
"@emotion/styled": "^11.3.0",
"@material-ui/core": "^5.0.0-beta.4",
"@material-ui/icons": "^5.0.0-beta.4",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
【问题讨论】:
我记录了一个问题:github.com/mui-org/material-ui/issues/27835。您可以在此处的存储库中找到正确的 TypeScript 代码:github.com/mui-org/material-ui/blob/v5.0.0-beta.4/docs/src/…。 【参考方案1】:试试
yarn add @mui/material @mui/icons-material @mui/styles
【讨论】:
以上是关于持久抽屉不适用于 material-ui v5的主要内容,如果未能解决你的问题,请参考以下文章
Material-UI injectionFirst 不适用于故事书
赛普拉斯测试 Material-UI 日期选择器不适用于 Github 操作
为啥 shadowColor: '...' - 不适用于“react-native-drawer”组件的 Android 上的抽屉样式?