eslint react exhaustive deps code example
Example 1: eslint exhaustive deps
// Your ESLint configuration
{
"plugins": [
// ...
"react-hooks"
],
"rules": {
// ...
"react-hooks/rules-of-hooks": "error", // Checks rules of Hooks
"react-hooks/exhaustive-deps": "warn" // Checks effect dependencies
}
}
Example 2: eslint exhaustive deps
npm install eslint-plugin-react-hooks --save-dev