簡體   English   中英

如何在 React 中從另一個組件重新渲染一個組件

[英]How to re-render a component from another component in React

我是新來的反應,這是我的問題,有沒有辦法從另一個組件重新渲染一個組件?

我正在使用 Redux,一些全局狀態正在影響組件 B。但是在我的示例中,組件 B 在某些 Redux 狀態從組件 C 發生變化后不會重新呈現。

組件C和B不是彼此的父/子,有沒有簡單的方法來做到這一點?

謝謝

我是新手,這是我的問題,有沒有辦法從另一個組件重新渲染一個組件?

I'm using Redux and some of the global state is effecting component B. But in my example component B is not re-rendered after some Redux state is changing from component C.

組件 C 和 B 不是父/子,有沒有簡單的方法?

謝謝

我是新手,這是我的問題,有沒有辦法從另一個組件重新渲染一個組件?

I'm using Redux and some of the global state is effecting component B. But in my example component B is not re-rendered after some Redux state is changing from component C.

組件 C 和 B 不是父/子,有沒有簡單的方法?

謝謝

我是新手,這是我的問題,有沒有辦法從另一個組件重新渲染一個組件?

I'm using Redux and some of the global state is effecting component B. But in my example component B is not re-rendered after some Redux state is changing from component C.

組件 C 和 B 不是父/子,有沒有簡單的方法?

謝謝

您可以使用useNavigate並導航到您所在的同一網址。 例如,作為函數的最后一行,您可以說navigate("/...your current url....")

window.location.reload()並不是每次都是最佳選擇。 它適用於本地主機,但例如當您使用“Netlify”等服務將其部署到互聯網時,它可能會導致“找不到 url”錯誤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM