[英]React access state of nested child components
我需要訪問(讀取和操作)不同組件的狀態。 不幸的是,這種情況不僅是“簡單”的 Parent <-> Child 關系,而且有點復雜。
SendResults有一個按鈕,如果單擊該按鈕,我想讀取Vote組件的狀態屬性。
我真的不知道如何解決這個問題。
這是組件圖:
Table TableHeader TableBody ResultRow Result Result ParticipantRow Vote Vote TableFooter SendResults
您可以使用Context API
(對於像這樣的簡單用例)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.