简体   繁体   English

如何修复eslint箭头主体错误的阻止语句?

[英]How to fix a block statement from a eslint arrow body error?

I have the following: 我有以下内容:

const MyPage = (props) => {
  return (
    <MyLayout {...props}>
      ...

I need to pass props to MyLayout, problem is eslint doesn't like this and is rejecting the code w: 我需要将道具传递给MyLayout,问题是eslint不喜欢这样,并且拒绝了代码w:

unexpected block statement surrounding arrow body 箭头主体周围出现意外的语句

How can I get the func to pass props and comply with eslint? 如何获得功能来传递道具并遵守eslint?

Thanks 谢谢

The problem is not with the props but around arrow body when you only have return inside it, you dont need to have curly brackets or return. 问题不在于道具,而在于箭身周围,当您仅在箭身内放回时,就不需要花括号或退回。

This will work. 这将起作用。

 const MyPage = (props) => <div> <MyLayout {...props}> .... </MyLayout> <MyComponent /> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决“箭头体周围出现意外的块语句; 在 =&gt;” ESLint 错误之后立即移动返回值? - How to fix “Unexpected block statement surrounding arrow body; move the returned value immediately after the =>” ESLint error? ESLint React错误箭头主体周围出现意外的块语句 - ESLint React error Unexpected block statement surrounding arrow body eslint错误:箭头主体周围出现意外的块语句 - eslint error: Unexpected block statement surrounding arrow body ESlint错误JS:箭头主体周围出现意外的块语句 - ESlint error JS : Unexpected block statement surrounding arrow body 使用 ESLint 围绕箭头主体的意外块语句 - Unexpected block statement surrounding arrow body with ESLint eslint:围绕箭头主体的意外块语句 - eslint: Unexpected block statement surrounding arrow body Eslint-箭头正文周围出现意外的语句块 - Eslint - Unexpected block statement surrounding arrow body ESLint:围绕箭头主体的意外块语句。 (箭头体式) - ESLint: Unexpected block statement surrounding arrow body. (arrow-body-style) 错误消息:&#39;箭头主体周围出现意外的块语句。 (箭头式) - Error message: 'Unexpected block statement surrounding arrow body. (arrow-body-style) 箭头主体周围出现意外的语句 - Unexpected block statement surrounding arrow body Promise
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM