简体   繁体   English

混淆react-redux和Container / Component

[英]Confuse on react-redux and Container/Component

I am new to React Native (and also javascript). 我是React Native的新手(也是javascript)。

I actually don't quite understand on the function "connect" in react-redux, and its relationship with Container/Component. 我实际上不太了解react-redux中的“ connect”功能及其与Container / Component的关系。

I saw the following code in container.js, how it actually affecting component.js? 我在container.js中看到了以下代码,它实际上如何影响component.js?

export default connect(state => ({
    state: state.counter
}),
(dispatch) => ({
    actions: bindActionCreators(counterActions, dispatch)
})
)(CounterApp); 

Thanks! 谢谢!

The connect function returns a modified version of your component CounterApp that has connect函数返回具有以下功能的组件CounterApp的修改版本:

  • been subscribed to changes in the store affecting it. 订阅了影响商店的更改。

  • is supplied with a state property containing the counter state. 提供了包含计数器状态的状态属性。

  • is supplied with an actions property (presumably) containing the action creators. 提供了包含操作创建者的操作属性(大概)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM