简体   繁体   English

当 store.dispatch(END) 出现 redux-saga 问题的下一个 js

[英]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的任何参数(例如reqresparams等); 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.

相关问题 在redux中,当编写请求调度时,“ next”和“ store.dispatch”之间有什么区别? - In redux when writing thunks for dispatch, what's the difference between “next” and “store.dispatch”? Redux store.dispatch 目的 - Redux store.dispatch purpose 如何在 Next.js + Redux-saga 中刷新 window 时设置授权 header? - How to set Authorization header when refresh window in Next.js + Redux-saga? Store.Dispatch() 重置 Redux Store - Store.Dispatch() Resetting Redux Store Redux 中的 store.dispatch 是同步还是异步 - Is store.dispatch in Redux synchronous or asynchronous 带有Redux的NextJS Redux-Saga初始化存储 - Nextjs with redux redux-saga initialize store Redux-Saga:Saga 有时在动作调度上不起作用 - Redux-Saga: Saga does not work sometimes on action dispatch 我们如何从 Redux - saga 中的 store.dispatch 返回 Promise - saga,以便我们可以等待解析然后在 SSR 中渲染? - How do we return a Promise from a store.dispatch in Redux - saga so that we can wait for the resolve and then render in SSR? 反应终极版中间件的#store.dispatch(动作)VS #next(动作) - React Redux middleware's #store.dispatch(action) vs #next(action) Redux-Saga连接多个发电机进行存储 - Redux-Saga connect multiple generators to store
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM