[英]In react, is it better to pass props to child components or using useSelector in child component?
例如我有3個組件,這里是嵌套關系
<a>
<b>
<c>
</c>
</b>
</a>
我應該在組件 a 中創建 useSelector 嗎? 並將道具傳遞給 c。 還是我應該只在 c 中使用選擇器? 主要區別是什么?
除非您需要來自Component a
中useSelector()
的一些數據,否則您可以選擇將其從Component a
中刪除並在Component c
中創建它。 或者您可以在Component a
和Component c
中使用它們
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.