我不想渲染冠軍時,說明空檢查反應元素爲空
var description = <MyElement />; // render will return nothing in render in some cases
if (!description) { // this will not work because its an object (reactelement)
return null;
}
<div>
{title}
{description}
</div>
請告訴我,而不是正確的方法!能夠檢查其是否爲空?
你有任何狀態/道具,你可以檢查看看_should_是否是空的?使用這些檢查更好,而不是檢查元素的孩子。 – J3Y
不是真的,數據是通過在myelement組件中轉換/過濾的某些道具構建的。如果沒有辦法,我需要將此Logik移動到父組件。然後我可以檢查這個道具。 –