I created a react app with npx create-react-app my-app and did a yarn install. Added the following to App.js:
const a = () => 1,
b = () => 2,
c = () => 3;
function App() {
const wut = useMemo(() => {
return { a: a(), b: b(), c: c() };
}, [a]);
useEffect(() => {
console.log(a(), b(), c());
}, [a]);
Yarn start will give me warnings but vscode does not.
I added .eslintrc.js with the following content:
module.exports = {
env: {
browser: true,
es6: true
},
extends: ["eslint:recommended", "plugin:react/recommended"],
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly"
},
parserOptions: {
ecmaFeatures: {
jsx: true
},
ecmaVersion: 2018,
sourceType: "module"
},
plugins: ["react"],
rules: {
"react/prop-types": [0],
"no-console": [0],
"react-hooks/exhaustive-deps": "warn"
}
};
The list of rules for react/recommended doesn't include react-hooks/exhaustive-deps.
You likely didn't install eslint-plugin-react-hooks.
It includes a note:
Note: If you're using Create React App, please wait for a corresponding release of react-scripts that includes this rule instead of adding it directly.
What version of c-r-a are you using? In theory it was added via this PR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With