![](/img/trans.png)
[英]In redux when writing thunks for dispatch, what's the difference between “next” and “store.dispatch”?
[英]Next js with redux-saga problem when store.dispatch(END)
大家好,我的代码类似于此https://github.com/vercel/next.js/tree/canary/examples/with-redux-saga 。
但是,当我尝试执行此代码时:
export const getStaticProps = wrapper.getStaticProps(async ({ store }) => {
store.dispatch(initCategoriesRequest());
store.dispatch(END);
await store.sagaTask.toPromise();
});
它说:
Error: Actions must be plain objects. Use custom middleware for async actions.
它指向store.dispatch(END)
。
此外,如果我使用async (ctx)
而不是async ({ store })
,我不会得到ctx
的任何参数(例如req
、 res
、 params
等); 只有商店。
也许问题出在配置上。
延迟响应,但您必须从 redux-saga 导入 END 操作。
例如
import { END } from 'redux-saga';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.