How to add multiple classes to a ReactJS Component?

后端 未结 29 2191
执念已碎
执念已碎 2020-11-27 09:16

I am new to ReactJS and JSX and I am having a little problem with the code below.

I am trying to add multiple classes to the className attribute on eac

29条回答
  •  温柔的废话
    2020-11-27 09:23

    Use https://www.npmjs.com/package/classnames

    import classNames from 'classnames';

    1. Can use multiple classes using comas seperated:

    2. Total
    3. Can use multiple classes using comas separated with condition:

    4. Hello World

    Using array as props to classNames will also work, but gives warning e.g.

    className={[classes.tableCellLabel, classes.tableCell]}
    

提交回复
热议问题