我想知道是否有一种方法可以访问 MyComponent 中的 theme.customElements.acitonButton 而不必使用 makeStyles?例如,我可以以某种方式输入 className={theme.customElements.actionButton} 吗?
主题.js
const theme = createMuiTheme({
customElements: {
actionButton: {
backgroundColor: '#007AFF'
}
}
})
export default theme
我的组件.tsx
import { makeStyles, createStyles, Theme } from '@material-ui/core'
// wondering if i can remove makeStyles and somehow access styles set in theme.js and add to <IconButton />?
const useStyles: any = makeStyles((theme: Theme) => {
return createStyles({
actionButton: theme.customElements.actionButton
})
})
const MyComponent: React.FunctionComponent<MyComponentProps> = props => {
const classes = useStyles()
<IconButton className={classes.actionButton} />
}