Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'xx' is not defined for arrow functions in react #1097

Closed
btmdave opened this issue Mar 24, 2018 · 3 comments

Comments

@btmdave
Copy link

commented Mar 24, 2018

I'm receiving errors that a function is not defined within a react component, on the line of the function, i.e.,

submit = () => {}

gives me 'submit' is not defined. I know I can // eslint-disable-line but is there anyway to have standard recognize this? I'm using with babel-eslint.

@LinusU

This comment has been minimized.

Copy link
Member

commented Mar 24, 2018

Are you intentionally trying to set a global variable? In that case, you can add /* global submit */ to the top of the file. Otherwise, you probably want const, let or var before that line, e.g:

const submit = () => {}
@btmdave

This comment has been minimized.

Copy link
Author

commented Mar 25, 2018

That was a method of a class, this is in a react component, such as:

class Example extends React.Component {
  submit = () => {}
}
@feross

This comment has been minimized.

Copy link
Member

commented May 16, 2018

This issue is fixed by updating to standard v11. Cheers!

@feross feross closed this May 16, 2018

@feross feross added the question label May 16, 2018

@lock lock bot locked as resolved and limited conversation to collaborators Aug 14, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
3 participants
You can’t perform that action at this time.