0
我當前的組件正在從其父節點接收作爲道具的節點。將道具添加到節點對象
假設
myComponent.propTypes = {
icon: PropTypes.node.isRequired,
}
哪裏圖標會收到類似
<Icon src="...." description="..." />
現在我的組件裏面我只需要添加
{} this.props.icon吃出呈現。
我需要的是一個道具的顏色=「#F00」添加到節點,在某種程度上,它導致
<Icon src="...." description="..." color="#f00"/>
我需要內部myComponent的做。不知道什麼是正確的語法來做到這一點。
不要吝嗇,但...你的問題到底是什麼? –
[如何將道具傳遞給{this.props.children}]可能的重複(http://stackoverflow.com/questions/32370994/how-to-pass-props-to-this-props-children) –
@erik -sn'你如何將一個道具添加到作爲道具傳遞的節點 – Snick