問題:
My structure looks as follows:我的結構如下:
Component 1
- |- Component 2
- - |- Component 4
- - - |- Component 5
Component 3
Component 3 should display some data depending on state of Component 5.組件 3 應根據組件 5 的狀態顯示一些數據。
Since props are immutable, I can't simply save its state in Component 1 and forward it, right?由於 props 是不可變的,我不能簡單地將它的狀態保存在組件 1 中並轉發它,對嗎? And yes, I've read about Redux , but I don't want to use it.是的,我讀過Redux ,但我不想使用它。 I hope that it's possible to solve it just with react.我希望可以通過反應來解決它。 Am I wrong?我錯了嗎?
解決方案:
參考一: https://en.stackoom.com/question/2P6r7參考二: https://stackoom.com/question/2P6r7