error:‘React Hook useEffect has a missing dependency:’
react报错
需要忽略这个警告吗?
src\page\home\deviceList\deviceList.jsx
Line 94:6: React Hook useEffect has a missing dependency: 'getgatewaydevice'. Either include it or remove the dependency array react-hooks/exhaustive-deps
src\page\home\gatewayConfig\gatewayConfig.jsx
Line 35:6: React Hook useEffect has a missing dependency: 'props.history'. Either include it or remove the dependency array react-hooks/exhaustive-deps
src\page\home\gatewayInfo\gatewayInfo.jsx
Line 70:17: Assignments to the 'setTime' variable from inside React Hook useEffect will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside useEffect react-hooks/exhaustive-deps
Line 80:6: React Hook useEffect has a missing dependency: 'history'. Either include it or remove the dependency array react-hooks/exhaustive-deps
src\page\home\gatewayInfo\upgrade\upgrade.tsx
Line 27:6: React Hook useEffect has a missing dependency: 'show'. Either include it or remove the dependency array react-hooks/exhaustive-deps
src\page\home\home.jsx
Line 89:5: React Hook useEffect has a missing dependency: 'props'. Either include it or remove the dependency array react-hooks/exhaustive-deps
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在仔细看看文档:
1.https://reactjs.org/docs/hook... effects每次更新都会执行
2.https://reactjs.org/docs/hook... 如何利用依赖列表来跳过effect
3.结尾还有一大段note,非常有用
总结:可以忽略,前提是你能准确的保证每个effect都在准确的实际被执行。