3

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>
  )
}

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

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

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

Parsing error: Unexpected token

3
  • Are you wanting to create a function (Facebook) that takes one object argument (with properties appId and url) or two arguments, appId and url?
    – Phil
    Feb 14, 2017 at 4:23
  • 1
    See github.com/eslint/eslint/issues/5498
    – Phil
    Feb 14, 2017 at 4:25
  • You can use eslint --fix to fix it automatically.
    – mysticatea
    Feb 14, 2017 at 5:30

1 Answer 1

2

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>
2
  • 1
    Following that comment you linked, it said to nuke the return and braces around it.
    – calebo
    Feb 14, 2017 at 4:56
  • @MayankShukla Yes.
    – calebo
    Feb 14, 2017 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.