我正在尝试创建一个自定义中间件,该中间件logout
根据 redux 中的某些条件调度操作(异步函数)。一旦动作被调度,它就会抛出错误RangeError: Maximum call stack size exceeded
商店.js:
const handleAction = (store) => (next) => (action) => {
const token = loadState(TOKEN);
const { userAccount } = store.getState();
if (token && userAccount.email) {
const decodedJwt = jwt_decode(token);
if (decodedJwt.exp < dayjs().unix()) {
store.dispatch(logoutAction());
}
}
return next(action);
};
export function configureStore(initState = {}) {
const store = createStore(
rootReducer,
initState,
composeEnhancers(applyMiddleware(thunk,handleAction))
);
return store;
}
我究竟做错了什么?提前致谢