我在 react 中有一小段代码
this.setState((prevState) => {
return { userAnnotations: [...prevState.userAnnotations, selText] };
});
当 ES Lint 给出错误 [eslint] Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the
时,我如何将其转换为单行=> . (arrow-body-style)
我尝试删除 return 周围的大括号,但随后发生了另一个错误。
请帮忙。
最佳答案
您需要做的就是摆脱return
this.setState(prevState => ({ userAnnotations:
[...prevState.userAnnotations, selText]
}))
关于javascript - ES6 胖箭头 react this.setState ESLint 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48785613/