warnings - useEffect/lint 警告会导致网页无法出现
问题描述
在 npm start 之后,我看到错误,并且当它出现时网页是空白的:
[frontend] Line 21:6: React Hook useEffect has a missing dependency: 'register'. Either include it or remove the dependency array react-hooks/exhaustive-deps
[frontend]
[frontend] ./src/components/user/findProperty/FindProperty.js
[frontend] Line 47:6: React Hook useEffect has a missing dependency: 'register'. Either include it or remove the dependency array react-hooks/exhaustive-deps
[frontend]
[frontend] ./src/components/user/dashboard/PastPayments.js
[frontend] Line 4:8: 'ChevronIcon' is defined but never used no-unused-vars
[frontend] Line 5:8: 'DownloadIcon' is defined but never used no-unused-vars
[frontend]
[frontend] ./src/components/common/alerts/Alerts.js
[frontend] Line 54:6: React Hook useEffect has an unnecessary dependency: 'fetchAlertData'. Either exclude it or remove the dependency array. Outer scope values like 'fetchAlertData' aren't valid dependencies because mutating them doesn't re-render the component react-hooks/exhaustive-deps
[frontend]
[frontend] ./src/components/user/pastBills/PastBills.js
[frontend] Line 66:6: React Hook useEffect has missing dependencies: 'history', 'params', 'serviceAccounts', and 'showFileInUrl'. Either include them or remove the dependency array react-hooks/exhaustive-deps
[frontend] Line 93:11: <iframe> elements must have a unique title property jsx-a11y/iframe-has-title
[frontend]
[frontend] ./src/components/user/dashboard/CustomerSvcTable.js
[frontend] Line 7:22: 'formatCurrencyNum' is defined but never used no-unused-vars
[frontend] Line 34:6: React Hook useEffect has a missing dependency: 'getSvcOrder'. Either include it or remove the dependency array react-hooks/exhaustive-deps
[frontend]
[frontend] ./src/components/user/layout/Layout.js
[frontend] Line 80:6: React Hook useEffect has a missing dependency: 'fetchInitialData'. Either include it or remove the dependency array react-hooks/exhaustive-deps
[frontend] Line 86:20: 'Tawk_API' was used before it was defined no-use-before-define
[frontend] Line 91:9: 'Tawk_LoadStart' is assigned a value but never used no-unused-vars
[frontend]
[frontend] ./src/components/common/navbar/Navbar.js
[frontend] Line 91:15: No duplicate props allowed react/jsx-no-duplicate-props
[frontend]
[frontend] ./src/components/common/card/Card.js
[frontend] Line 94:21: Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener react/jsx-no-target-blank
[frontend]
[frontend] Search for the keywords to learn more about each warning.
[frontend] To ignore, add // eslint-disable-next-line to the line before.
我的问题是,我是否需要将缺少的依赖项添加到前端的 package.json 中?如果我执行 npm install ,我确信它们会消失,但我不清楚永久修复。依赖列表项是否有顺序?浏览器弹出一个空白屏幕,但浏览器调试工具没有显示我可以看到的错误。我可以继续忽略 lint 错误而不像他们在这里讨论的那样将它们添加到 useEffect吗?我无法找到在我的代码中添加什么/在哪里添加它。
解决方案
我发现链接出现在 IE 中。当我将它移到 Edge 时,网页不是空白的,我也没有看到链接警告。
推荐阅读
- angular - 在 Angular 中使用 forkJoin 时的可重用搜索
- amazon-web-services - 在免费 AWS 层上运行 LAMP 和 Certbot 的 Ubuntu 出现 SSL 超时问题
- php - 通过ajax发送一个php var
- python - 使用 row 函数获取 nan。但是,在将行与 nan 进行比较时,条件变为 False
- docusignapi - 如何在 NetSuite 中将文件(例如 PDF)编码为 base64
- c# - 从不在 MyList 中的实体中选择
(字段)使用实体框架 - php - 使用一个键数组过滤另一个数组,保持“顺序”
- rust - 将参数/标志传递给`build.rs`
- matlab - 在matlab的列中拆分行
- php - 脚本更新 database.php Laravel