天真地连接到同一页面中的两个redux

时间:2019-03-05 09:31:43

标签: reactjs react-native redux react-redux

这是我连接到RegisterUser redux的方式  我想连接到另一个Redux

RegisterUser将数据发送到api 在第二个redux中,我想从api获取任务,但是当我尝试连接另一个redux时,出现此错误

连接组件时mapstatetoprops参数的类型对象的无效值

 const mapStateToProps = state => {
return {
   errorid: state.RegisterR.errorid,
    loading: state.RegisterR.loading,
    registersucsess:state.RegisterR.registersucsess
}}


 export default connect(mapStateToProps, { RegisterUser })(Register);






what i try to do something like this const mapStateToProps = state => {
return {
    errorid: state.RegisterR.errorid,
    loading: state.RegisterR.loading,
    registersucsess:state.RegisterR.registersucsess,


    data: state.taskList.data}}

export default connect(mapStateToProps, {fetchTasks},{ RegisterUser })(Register);

1 个答案:

答案 0 :(得分:0)

谢谢,我只有一家商店
 

并且我结合了来自'redux'的我的reducer import {CombineReducers};

我想在同一屏幕上使用两个动作

我设法做到这一点

const mapStateToProps = state => {
return {
    errorid: state.RegisterR.errorid,
    loading: state.RegisterR.loading,
    registersucsess:state.RegisterR.registersucsess,

    data: state.taskList.data // this is for fetchTasks }}

export default connect(mapStateToProps, { RegisterUser ,fetchTasks})(Register);