我正在
Uncaught RangeError: Maximum call stack size exceeded
at eval (index.js?4bd6:38)
at Object.dispatch (applyMiddleware.js?6ce6:35)
at dispatchChildActions (index.js?4bd6:33)
at eval (index.js?4bd6:39)
at Object.dispatch (applyMiddleware.js?6ce6:35)
at dispatchChildActions (index.js?4bd6:33)
at eval (index.js?4bd6:39)
at Object.dispatch (applyMiddleware.js?6ce6:35)
at dispatchChildActions (index.js?4bd6:33)
当我尝试将redux-batched-actions
中间件添加到我的applyMiddleware()
const store = createStore(
enableBatching(appReducer), // added enableBatching
composeWithDevTools(
applyMiddleware(
batchDispatchMiddleware, // and this
sagaMiddleware,
historyMiddleware,
)
)
)
什么错了?
答案 0 :(得分:3)
我花时间为您完成了源代码。这是一个包错误。我已提交了pull request。
之前的合并导致无限递归,其中重复调度非批处理操作。我还认为您应该只根据您的使用情况使用中间件或更高阶的缩减器,请参阅自述文件以获得一个小的解释。 请尝试修复并告诉我,因为我目前没有设置项目。
希望这能解决您的问题!
答案 1 :(得分:0)
不确定。
以下代码对我有用,也许会有所帮助:
const composeEnhancers =
typeof window === 'object' &&
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
}) : compose;
const enhancers = composeEnhancers(
applyMiddleware(ReduxThunk),
autoRehydrate()
);
const initialState = {};
const store = createStore(
reducers,
initialState,
compose(enhancers)
);
persistStore(store);
ReactDOM.render(
<Provider store={store}>
<div>
<BrowserRouter>
<Switch>
<Route exact path="/" component={Home} />
<Route path="/xxx" component={XXX} />
</Switch>
<Footer />
</Container>
</BrowserRouter>
</div>
</Provider>
, document.querySelector('#app'));
答案 2 :(得分:0)
当我用括号包裹我的行为时,我有同样的错误:
return bindActionCreators(...TaskActions, ...UserActions, dispatch)
而不是
return bindActionCreators({...TaskActions, ...UserActions}, dispatch)