2016-12-05 58 views
0

我是React Native(也是JavaScript)的新手。混淆react-redux和容器/組件

我其實並不很瞭解react-redux中的「connect」函數,以及它與Container/Component的關係。

我在container.js中看到了下面的代碼,它是如何影響component.js的?

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

謝謝!

+0

你真的應該檢查http://redux.js.org/docs/basics/UsageWithReact.html來獲取基礎知識:) –

回答

0

connect函數返回你的組件CounterApp

  • 已經訂閱了影響其店裏變化的修改版本。

  • 提供了一個包含計數器狀態的狀態屬性。

  • 提供了包含動作創建者的動作屬性(假定)。