【发布时间】:2020-12-05 10:26:42
【问题描述】:
我正在使用react-frame-component 加载我创建的自定义组件,该组件使用material ui 和styled-components。
我创建的自定义组件无关紧要,但包含以下相关代码:
const StyledCardHeader = styled(({ isRTL, ...rest }) => (
<CardHeader {...rest} />
))`
${({ theme, isRTL }) => `
& .MuiCardHeader-title {
margin-right:${isRTL ? 0 : theme.spacing(2)}px;
margin-left: ${isRTL ? theme.spacing(2) : 0}px;
}
`};
`;
当它渲染时,实际的类名变得比我预期的不同:MuiCardHeader-title-34(它添加了 34 作为后缀 - 随机数)。
因此,我的自定义样式没有被应用。
【问题讨论】:
标签: reactjs iframe material-ui styled-components