我在我的 React typescript 项目中使用
airbnb
更新了我的 Eslint 规则。
我现在收到这些错误:
React Hook useCallback 缺少依赖项:“setCookie”。任何一个 包含它或删除依赖项 array.eslintreact-hooks/exhaustive-deps
我在 eslintrc.js 的扩展属性中有这个:
extends: [
'airbnb',
'airbnb-typescript',
'airbnb/hooks',
'plugin:react/recommended',
'plugin:jest/recommended',
'plugin:prettier/recommended',
],
如何正确修复这些错误?什么时候添加或不添加依赖属性是一个好习惯?
如果你完全删除它,那将是非常糟糕的体验,而不是抛出错误,我想通过将其添加到你的 eslintrc 规则中来抛出警告:
"react-hooks/exhaustive-deps": "warn"