Material ui 如何将mui主题颜色导入组件?

Material ui 如何将mui主题颜色导入组件?,material-ui,Material Ui,我想导入Mui主题颜色以将其值传递给组件。如何导入颜色 const WonderChart = () => { return ( <WonderChart lineColor={theme.palette.primary.main} /> ) } const WonderChart=()=>{ 返回( ) } useThemehook可用于此操作。 从'@materialui/core/styles'导入{useTheme}; 常数WonderChart=

我想导入Mui主题颜色以将其值传递给组件。如何导入颜色

const WonderChart = () => {

  return (
    <WonderChart lineColor={theme.palette.primary.main} />
  )
}
const WonderChart=()=>{
返回(
)
}

useTheme
hook可用于此操作。

从'@materialui/core/styles'导入{useTheme};
常数WonderChart=()=>{
const theme=useTheme()
返回(
)
}

很酷,非常感谢!
import { useTheme } from '@material-ui/core/styles';


const WonderChart = () => {
  const theme = useTheme()
  return (
    <WonderChart lineColor={theme.palette.primary.main} />
  )
}