我有两个saga被调用到同一个page.But上,然后只看到一个saga结果。另一个传奇没有执行,我看不到结果。
AdminFolder
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并不能正常工作。让我知道我要去哪里,wrong.have我错过了什么?任何帮助都是非常感谢的。
发布于 2019-04-11 19:46:48
我的错,进口是错的
下面的代码很有吸引力:)
export default function *rootSaga(){
yield fork(actionWatcherSalesData)
yield fork(actionWatcherMostBrought)
}https://stackoverflow.com/questions/55628958
复制相似问题