typescript - 升级到 rc.0 时 Material-UI v5 typescript 错误
问题描述
我刚刚将我的 material-ui 升级到 v5-rc.0 并尝试使用styled-components
. 但是,在我的Component.styles.ts
文件中出现错误:
如果不引用“@mui/material/node_modules/@types/react”,则无法命名推断的“StyledStepper”类型。这可能是不可移植的。类型注释是必要的。
这是我的文件:
import { styled } from '@mui/material/styles';
import Stepper, { stepperClasses } from '@mui/material/Stepper';
import StepConnector, { stepConnectorClasses } from '@mui/material/StepConnector';
import { stepLabelClasses } from '@mui/material/StepLabel';
export const StyledStepper = styled(Stepper)(({ theme }) => ({
[`&.${stepperClasses.alternativeLabel}`]: {
[`.${stepLabelClasses.root}`]: {
flexDirection: 'column-reverse',
},
...
有谁知道这个错误是什么意思?
解决方案
将样式从另一个文件传递给sx
道具时,我遇到了类似的问题
我发现的是这个我不确定它是否有帮助,但看看
我必须导出每种样式,as const
就像这样:
export const logoHeadersContainer= {
flexDirection: 'column',
alignItems: 'center',
} as const;
推荐阅读
- ruby-on-rails - 带有 Cocoon 的动态表单 - NilClass:Class 的未定义方法“reflect_on_association”:
- android - 无法使用 RobolectricTestRunner 和 Koin 运行单元测试
- jquery-ui - Jqueryui datepicker change class onselect doesn´t work
- pytorch - 在pytorch中实现将旋转矩阵转换为旋转向量
- amazon-web-services - 将弹性 IP 与 AWS 负载均衡器结合使用
- python - Python 另一个嵌套列表
- python-3.x - 在python中提取两个列表之间的最长公共路径
- java - Android: OnClick not work when override onClick in customView
- networkx - networkx ego_graph 适用于 geopandas 系列加速
- javascript - How can I reverse date time to ajax date time