How to add multiple classes to a ReactJS Component?

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

    I usually use it like this : (in your case)

        
  • When it comes to JSX and (usually) we have some json... than you loop it ... component.map, plus some conditional to check if json property exists to render class name depending on property value from JSON. In example below component_color and component_dark_shade are properties from component.map()

       

    Output :

    Or:
    depending on values from map...

提交回复
热议问题