[英]Warning: Array.prototype.reduce() expects a return value from arrow function
const singleParams = [...appliedFilters].reduce((prev, curr) => {
if (curr.key !== "multi")
return { ...prev, ...curr.selectedValue.params };
return;
}, {});
The following function is giving me the following warning in my console.以下 function 在我的控制台中给了我以下警告。
Line 22:13: Array.prototype.reduce() expects a return value from arrow function array-callback-return
第 22:13 行:Array.prototype.reduce() 期望箭头 function 数组回调返回的返回值
I can't ignore it since I won't be able to deploy with warnings.我不能忽略它,因为我将无法部署警告。 How do I fix it?
我如何解决它?
You need to return prev
in else block您需要在 else 块中返回
prev
const singleParams = [...appliedFilters].reduce((prev, curr) => {
if (curr.key !== "multi")
return { ...prev, ...curr.selectedValue.params };
return prev;
}, {});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.