Definition for rule 'react-hooks/exhaustive-deps' was not found

后端 未结 4 729
盖世英雄少女心
盖世英雄少女心 2021-02-18 19:00

I am getting the following eslint error after adding // eslint-disable-next-line react-hooks/exhaustive-deps in my code.

8:14 error Definit

相关标签:
4条回答
  • 2021-02-18 19:05

    This typically happens because the react-hooks plugin is missing in the .eslintrc plugin configuration. Ensure you have added react-hooks as in the example below:

    "plugins": ["react", "react-hooks",],
    
    0 讨论(0)
  • 2021-02-18 19:10

    Make sure you define your react-hooks both in extends and plugins array like this

    "extends": [
        "react-hooks",
      ],
      "plugins": [
        "react-hooks"
      ],
    
    0 讨论(0)
  • 2021-02-18 19:12

    Not a perfect solution but changing:

    // eslint-disable-next-line react-hooks/exhaustive-deps
    

    to:

    // eslint-disable-next-line
    

    suppressed that error.

    0 讨论(0)
  • 2021-02-18 19:13

    Make sure you have put the rule in the rules object in your .eslintrc. Installing the plugin alone is not enough for the rules to start working

    "react-hooks/exhaustive-deps": "warn",
    

    and I assume you have already added react-hooks plugin into the plugins array in the .eslintrc

    0 讨论(0)
提交回复
热议问题