Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/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_React Redux_Redux Saga - Fatal编程技术网

Reactjs react redux传奇在哪里处理一些逻辑

Reactjs react redux传奇在哪里处理一些逻辑,reactjs,react-redux,redux-saga,Reactjs,React Redux,Redux Saga,我正在使用React的redux传奇。假设我正在从服务器获取一些需要外部客户端计算的数据。我的问题是把它们放在哪里。 我的传奇故事是这样的: 函数*someEffect(动作){ 试一试{ //没有从代码中删除任何相关内容。 const data=yield调用(someRequestFunctionStatuseAxios,requestparams); 如果(data.status>=200&&data.status正如您所说的reducer不是修改API响应的最佳位置,那么saga也不是

我正在使用React的redux传奇。假设我正在从服务器获取一些需要外部客户端计算的数据。我的问题是把它们放在哪里。 我的传奇故事是这样的:

函数*someEffect(动作){
试一试{
//没有从代码中删除任何相关内容。
const data=yield调用(someRequestFunctionStatuseAxios,requestparams);

如果(data.status>=200&&data.status正如您所说的
reducer
不是修改API响应的最佳位置,那么saga也不是

我建议您在axios中使用
transformResponse
函数,在从API返回响应后立即修改响应

axios.get('/', {
   transformResponse: (data) => { 
      // do whatever you like with the data
   },
});

在Axiosa中使用
transformResponse
另一种方法是在
mapStateToProps
中进行计算,并将结果作为组件的道具传递。使用
选择器
重新选择
可能有些过分,但适用于大型应用程序。我不知道这种功能。感谢您的回复。我会查看它