[英]Next js with redux-saga problem when store.dispatch(END)
Hello guys my code is similar to this https://github.com/vercel/next.js/tree/canary/examples/with-redux-saga .大家好,我的代码类似于此https://github.com/vercel/next.js/tree/canary/examples/with-redux-saga 。
However, when I try to do this code:但是,当我尝试执行此代码时:
export const getStaticProps = wrapper.getStaticProps(async ({ store }) => {
store.dispatch(initCategoriesRequest());
store.dispatch(END);
await store.sagaTask.toPromise();
});
It says:它说:
Error: Actions must be plain objects. Use custom middleware for async actions.
and it points to store.dispatch(END)
.它指向
store.dispatch(END)
。
Also, if i put async (ctx)
instead of async ({ store })
, I don't get any paramters (for example req
, res
, params
, etc.) for ctx
;此外,如果我使用
async (ctx)
而不是async ({ store })
,我不会得到ctx
的任何参数(例如req
、 res
、 params
等); there's only the store.只有商店。
Maybe the problem is something with the configuration.也许问题出在配置上。
Late response, but you must import the END action from redux-saga.延迟响应,但您必须从 redux-saga 导入 END 操作。
eg例如
import { END } from 'redux-saga';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.