Passing object as props to jsx

前端 未结 4 1417
傲寒
傲寒 2020-12-13 08:01

I have an object contains multiple common key-value props, that I want to pass on to some jsx. Something like this:

const commonProps = {myProp1: \'prop1\',         


        
4条回答
  •  再見小時候
    2020-12-13 08:39

    You can use the spread operator to do this.

    You can simply do

    Now what all individual properties you have in commonProps will be sent as individual props to MyJsx.

提交回复
热议问题