React.js中的Eslint箭头式样式错误 [英] Eslint arrow-body-style error in react.js

查看:145
本文介绍了React.js中的Eslint箭头式样式错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Airbnb的eslint规则,我的反应代码中出现以下错误,但我不确定是什么错误.

Using Airbnb's eslint rules, I'm getting the following error in my react code but I'm not sure what's the error.

const Facebook = ({ appId, url }) => {
  return (
    <div className={styles.facebook}>
      <FacebookProvider appID={appId}>
        <EmbeddedPost href={url} width="auto" />
      </FacebookProvider>
    </div>
  )
}

在第1行{括号的开头出现错误.

Getting an error at the beginning of line 1 { bracket.

箭头主体周围出现意外的语句块. (箭头式)

Unexpected block statement surrounding arrow body. (arrow-body-style)

尝试将大括号括起来并用括号括起来,但又在<div>的第3行周围出现另一个错误.

Tried wrapping the curly brackets with parenthesis brackets but in turn, another error appear around line 3 of <div>.

解析错误:意外的令牌

Parsing error: Unexpected token

推荐答案

尝试按照

Try removing the curly braces and the return as per the issue linked in the comment for your question:

const Facebook = ({ appId, url }) => 
    <div className={styles.facebook}>
        <FacebookProvider appID={appId}>
            <EmbeddedPost href={url} width="auto" />
        </FacebookProvider>
    </div>

这篇关于React.js中的Eslint箭头式样式错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆