Reactjs React Redux应用程序中的常见错误处理
我的应用程序通过不同的操作一次调用多个api。假设4/12操作给出了错误响应,存储需要获得所有错误消息的更新(一个由4条错误消息组成的数组)。最后,我需要显示所有4个错误Reactjs React Redux应用程序中的常见错误处理,reactjs,redux,react-redux,redux-thunk,Reactjs,Redux,React Redux,Redux Thunk,我的应用程序通过不同的操作一次调用多个api。假设4/12操作给出了错误响应,存储需要获得所有错误消息的更新(一个由4条错误消息组成的数组)。最后,我需要显示所有4个错误 标题处的弹出窗口。我听说过redux catch。任何人都可以用示例代码解释。如果您使用的是中间件 import { createStore, applyMiddleware } from 'redux'; import reduxCatch from 'redux-catch'; import reducer from
标题处的弹出窗口。我听说过redux catch。任何人都可以用示例代码解释。如果您使用的是中间件
import { createStore, applyMiddleware } from 'redux';
import reduxCatch from 'redux-catch';
import reducer from './reducer';
function errorHandler(error, getState, lastAction, dispatch) {
console.error(error);
console.debug('current state', getState());
console.debug('last action was', lastAction);
// optionally dispatch an action due to the error using the dispatch parameter
}
const store = createStore(reducer, applyMiddleware(
reduxCatch(errorHandler)
));
请参阅上的详细文档
此外,请检查以下问题:
如果您使用的是中间件
import { createStore, applyMiddleware } from 'redux';
import reduxCatch from 'redux-catch';
import reducer from './reducer';
function errorHandler(error, getState, lastAction, dispatch) {
console.error(error);
console.debug('current state', getState());
console.debug('last action was', lastAction);
// optionally dispatch an action due to the error using the dispatch parameter
}
const store = createStore(reducer, applyMiddleware(
reduxCatch(errorHandler)
));
请参阅上的详细文档
此外,请检查以下问题:
这是否回答了您的问题?这回答了你的问题吗?