[英]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.