商店更新时 Redux 更新反应组件

Redux update react component when store updates

在纯 React 中,我可以将道具传递给子组件并重新呈现。我也想在 Redux 中拥有相同的功能。

我想要一个连接到 Redux 商店的组件,每当商店更新时(理想情况下商店中有 select 个元素),该组件就会重新呈现(因此不直接分派操作)。我如何在 Redux 中实现这一点?

谢谢

Redux 文档中的官方 React-Redux library provides this capability, with a method called connect that generates store-connected wrapper components. Please see the Usage with React 部分。

为什么很少有人阅读文档?

如果你这样做了,你会发现 Redux 的创造者 Dan Abramov 通过他的 Getting started with Redux video tutorials linked from the Redux GitHub page.

对 Redux 进行了精彩的介绍

视频 24-26(共 30 个,平均一个 3 分钟)Dan 很好地解释了您的要求。

我建议从头开始观看整个系列,因为它提供了有关 Redux 内部工作原理的良好基础,这对于在后面的视频中使用(帮助)库 React-Redux 很有帮助.