【发布时间】: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,一切都不起作用。请让我知道我要去哪里错了。我错过了什么吗? 任何帮助表示赞赏。
【问题讨论】: