ESLint错误围绕箭头主体的意外阻止语句

时间:2017-03-30 05:02:12

标签: reactjs ecmascript-6 eslint

我在我的项目中使用ESlint。我收到错误**来自此函数的箭头体**的意外阻止语句

const toggleDrawer = (state) => {
 return {
 ...state,
 drawerExpanded: !state.drawerExpanded,
 };
};

有人可以建议我如何处理这个ESlint错误吗?

1 个答案:

答案 0 :(得分:1)

将对象包裹在括号()

const toggleDrawer = (state) => ({
 ...state,
 drawerExpanded: !state.drawerExpanded,
});

同时检查您是否在es-lint中有arrow-body-style: ["error", "as-needed"]