'Missing dependencies warning React doesn\t show up

I have an issue where the missing dependencies warning doesn't show up any longer for useEffect in React. I am using VS Code if that matters.

Does anyone know what could be the cause for this, as right now I don't even know where to start debugging.



Solution 1:[1]

your problem is related with eslint.

check your code to see is there any line of code like this?

 // eslint-disable-next-line

or this:

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

if yes, delete it.

another cause can be the .eslintignore file. check if there is this .eslintignore file exists on your project, delete it should solve your problem

Solution 2:[2]

In VS Code, press Ctrl + Shift + P to bring the command prompt, and run ESLint: Show Output Channel. If ESLint is missing certain React plugins, it will tell you so.

It might also be something wrong with VS Code's TS server. It is the thing that is checking for dependencies, amongst other things. Open the terminal (Ctrl + '), select the Output tab, and on the right hand side select Typescript from the dropdown menu.

If you are using Yarn v3, you need to install eslint and typescript as dev dependencies, then run yarn dlx @yarnpkg/sdks vscode and switch VS Code to the workspace version of Typescript (the prompt for that will show in a popup).

Solution 3:[3]

In my case, I am using React Extension Pack where some of included extension was already installed in my Vs Code. Then I uninstalled all included extension, after that again install React Extension Pack, and automatically removed all issues.

Solution 4:[4]

You may have disabled the react-hooks/exhaustive-deps eslint rule or extended an eslint ruleset which disables it. Make sure that the follow line is absent in any of the eslint configurations used:

'react-hooks/exhaustive-deps': 'off'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohammad Taheri
Solution 2 Summer
Solution 3 nurmdrafi
Solution 4 alexanderdavide