在 Redux 中将多个状态与相应的动作创建者连接起来的正确方法是什么?这甚至是个好主意吗?如果这是一个愚蠢的想法,我该如何解决?
export default connect(
// which part of the Redux global state does
// our component want to receive as props?
(state) => {
return {
state: state.instagram
};
},
// which action creators does
// it want to receive by props?
(dispatch) => {
return {
actions: bindActionCreators(instagramActions, dispatch)
};
}
)(FeedContainer);
我基本上想要的是这样的:
...
state: {state.instagram, state.facebook}
...
...
const mergedActions = {instagramActions, facebookActions};
actions: bindActionCreators(mergedActions , dispatch)
...