React: adding props to an existing component

后端 未结 3 1376
孤独总比滥情好
孤独总比滥情好 2021-01-31 13:57

I\'m trying to figure out how to clone an existing element with additional props.

For reference:

this.mainContent = 

        
3条回答
  •  甜味超标
    2021-01-31 14:14

    If you don't want to use React.cloneElement(), you can use the following snippet:

    function AddExtraProps(Component, extraProps) {
        return ;
    }
    

提交回复
热议问题