我正在开发基于ssr + redux-saga的应用程序。 而且我有一个错误:“动作必须是普通对象。将自定义中间件用于异步动作。”
在研究过程中,我得出的结论是,错误可能是由商店的创建引起的。
如何更改可在redux-saga中使用的代码?
我的创建商店看起来像next(本地,而不是ssr):
const history = isServer
? createMemoryHistory({
initialEntries: [url]
})
: createBrowserHistory();
const sagaMiddleware = createSagaMiddleware();
const enhancer = compose(applyMiddleware(
routerMiddleware(history), sagaMiddleware));
const store = initialState => {
const store = createStore(connectRouter(history)
(rootReducer),
initialState, enhancer);
sagaMiddleware.run(Sagas);
通常,我只想在下面的链接中从redux-thunk到redux-saga重写应用程序。在此链接中只需存储(local + ssr) https://github.com/mnsht/cra-ssr/blob/master/src/store.js