ESLint Airbnb ES6 和 Redux Async Action Unexpected block statements arounding arrow body

ESLint Airbnb ES6 and Redux Async Action Unexpected block statement surrounding arrow body

我做错了什么?我有其他三个异步操作也有同样的问题,但无法修复。

当您查看 Arrow Function Documentation

(param1, param2, …, paramN) => expression
// equivalent to:  => { return expression; }

"Unexpected block statement surrounding arrow body" 只是意味着您不需要 { return expression; } 此处的箭头函数块,因为默认情况下箭头函数需要 return。

const getOptions = () => (dispatch, getState) => {} 

等同于

const getOptions = () => { return (dispatch, getState) => {} }

因此块语句是不必要的

不推荐:
您始终可以禁用 arrow-body-style 规则或以不会出现此类错误的方式对其进行配置。

推荐:

const getOptions = () => ( dispatch, getState ) => {
    const {user} = getState();
    //rest of the code
}


这基本上意味着当我们只返回 w/o 做任何其他事情时我们不必写 { return 东西