将className作为其他prop而不是styleName

时间:2017-10-30 17:03:20

标签: reactjs babel-plugin-react-css-modules

如何将CSS模块类名称作为与styleName不同的支柱传递?

import './MyStyles.css'

<ThirdPartyComponent
  styleName='this-works'
  activeClassName='i want to pass my css module classes here' />

1 个答案:

答案 0 :(得分:3)

import styles from './MyStyles.css'

<ThirdPartyComponent
    className={styles['this-works']}
    activeClassName={styles['my-css-module-class-name']}
/>