How to add multiple classes to a ReactJS Component?

后端 未结 29 2211
执念已碎
执念已碎 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:24

    It can be done with https://www.npmjs.com/package/clsx :

    https://www.npmjs.com/package/clsx

    First install it:

    npm install --save clsx
    

    Then import it in your component file:

    import clsx from  'clsx';
    

    Then use the imported function in your component:

提交回复
热议问题