Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs React Redux应用程序中的常见错误处理_Reactjs_Redux_React Redux_Redux Thunk - Fatal编程技术网

Reactjs React Redux应用程序中的常见错误处理

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

我的应用程序通过不同的操作一次调用多个api。假设4/12操作给出了错误响应,存储需要获得所有错误消息的更新(一个由4条错误消息组成的数组)。最后,我需要显示所有4个错误
标题处的弹出窗口。我听说过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)
));
请参阅上的详细文档

此外,请检查以下问题:


这是否回答了您的问题?这回答了你的问题吗?