請你能幫我理解什麼是對應React元素的相應JSX語法?如何將具有大量屬性的對象作爲道具傳遞給React元素?
const data = {
className: "myEl",
"data-numb": 3,
"data-created": 191017
//following other 20 attributes
}
React.createElement("div",data,"test");
我猜你會不會寫在JSX語法此元素以這種方式
<div className="myEl" data-numb=3 data-created=191037 ....the other 20 attributes.... />
那麼,什麼是通過作爲道具的陣營元素,有一個巨大的物體的理想方式屬性的數量?
爲什麼不只是在子組件中傳遞data = data和access作爲this.props.data.className? –
@chandrasugur - 使用淺等於比較(反正在PureComponents上)對狀態和道具進行重新渲染的目的將是避免這種情況的一個原因。 – Adam
@Adam很高興認識這個。謝謝。 –