![](/img/trans.png)
[英]Child component will only re-render when Parent component's button, Submit, is clicked twice
[英]Re-render child component when back button is clicked
我想知道是否有任何簡單的方法可以在單擊后退按鈕時重新渲染單個子組件。 例如:
componentWillReceiveProps: function() {
forceupdate > child-one
}
<parent>
<child-one />
<child-two />
</parent>
每當單擊后退按鈕時,都會點擊componentWillReceiveProps
。
有什么想法嗎? 我不想重新渲染整個父組件。
如果出於某種原因您希望孩子們重新渲染,您可以使用傳遞給他們的 key 道具。 React Reconciliation 使用的這個 key prop 只會拋出舊組件並創建一個新組件,從而重新渲染。
<parent>
<child-one key={control} />
<child-two />
</parent>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.