-1

I am working on a React project, I configured ESLint in my project. After that configuration, I got the error that I mention below in the image:

Error throwing in the arrow function

Why is ESLint throwing this error and how to solve this?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Raghul SK
  • 1,256
  • 5
  • 22
  • 30

5 Answers5

0

you should declare the function with const.

const loginError = props => {
  ...
}
gazdagergo
  • 6,187
  • 1
  • 31
  • 45
0

You need to declare the arrow function loginError with either var let or const.

apena
  • 2,091
  • 12
  • 19
0

check out Error Handling. try & catch functions cleaner code

farukbigez
  • 170
  • 1
  • 10
0

basically you should get 'loginError is not defined' if that was lint, but this error is for latest ES6. My eslintrc.json is

{
    "parser": "babel-eslint",
    "env": {
        "browser": true,
        "es6": true
    },
    "extends": [
        "plugin:react/recommended",
        "standard",
        "eslint:recommended"
    ],
    "globals": {
        "Atomics": "readonly",
        "SharedArrayBuffer": "readonly"
    },
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": 2018,
        "sourceType": "module"
    },
    "plugins": [
        "react"
    ],
    "rules": {
    },
    "settings": {
        "react": {
            "createClass": "createReactClass", // Regex for Component Factory to use,
                                               // default to "createReactClass"
            "pragma": "React",  // Pragma to use, default to "React"
            "version": "detect", // React version. "detect" automatically picks the version you have installed.
                                 // You can also use `16.0`, `16.3`, etc, if you want to override the detected value.
                                 // default to latest and warns if missing
                                 // It will default to "detect" in the future
            "flowVersion": "0.53" // Flow version
          },
          "propWrapperFunctions": [
              // The names of any function used to wrap propTypes, e.g. `forbidExtraProps`. If this isn't set, any propTypes wrapped in a function will be skipped.
              "forbidExtraProps",
              {"property": "freeze", "object": "Object"},
              {"property": "myFavoriteWrapper"}
          ],
          "linkComponents": [
            // Components used as alternatives to <a> for linking, eg. <Link to={ url } />
            "Hyperlink",
            {"name": "Link", "linkAttribute": "to"},
            {"name": "a", "linkAttribute": "href"}
          ]
    }
}
pramod singh
  • 503
  • 2
  • 11
0

Add type before loginError ...

eg :

const loginError = props => { ... }

var loginError = props => { ... }

Jeeva
  • 3
  • 1