【问题标题】:Redux-saga - yield all is not calling all my sagas in root sagaRedux-saga - yield all 并不是在 root saga 中调用我所有的 saga
【发布时间】:2019-04-11 09:20:22
【问题描述】:

我有两个 saga 被调用到同一个页面上。但是只有一个 saga 结果被看到。 另一个 saga 没有执行我没有看到结果。

管理员文件夹

dashboard.js

               const mapStateToProps=state=>{
                console.log(state)
                return{   
                    dataSales:state.salesDataReducer,
                    mostBrought:state.mostBroughtReducer
                }
                };

                const mapDispatchToProps = {
                    getSales:getSales,
                    getMostBrought:getMostBrought
                };

rootSaga/rootSaga.js

                import actionWatcherSalesData from '../adminDashboard/salesDataSaga';
                import actionWatcherMostBrought from '../adminDashboard/mostBroughtSaga';
                import {all,call} from 'redux-saga/effects';



                export default function *rootSaga(){
                    yield all([
                    call( actionWatcherSalesData), //works
                    call(actionWatcherMostBrought)// this saga doesn't call up no data found 
                    ]);
                }

                    export default function *rootSaga(){
                    yield all([
                    fork( actionWatcherSalesData),
                    fork(actionWatcherMostBrought)//doesnt work
                    ]);
                }

saga1.js

 yield takeLatest(GET_SALES_DATA,getSales)

saga2.js

 yield takeLatest(GET_MOST_BROUGHT_DATA,getMostBrought);

是导致问题的 takeLatest 吗?

1)由于其相同的页面数据,两个调用都必须异步发生,但第二个 saga 调用没有被调用? 2)我怀疑对于我在其他页面上的应用程序,我只有在点击时才会有一个按钮,它必须调用 saga 是否应该包含在此处?

在这个调用中,fork,一切都不起作用。请让我知道我要去哪里错了。我错过了什么吗? 任何帮助表示赞赏。

【问题讨论】:

    标签: react-redux redux-saga


    【解决方案1】:

    我的错误是导入错误

    下面的工作就像一个魅力:)

      export default function *rootSaga(){
       yield fork(actionWatcherSalesData)
       yield fork(actionWatcherMostBrought)
       }
    

    【讨论】:

      猜你喜欢
      • 2018-06-03
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 2018-09-03
      • 1970-01-01
      • 2017-09-12
      • 1970-01-01
      • 2017-06-14
      相关资源
      最近更新 更多