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
在仔细看看文档:
1.https://reactjs.org/docs/hook... effects每次更新都会执行
2.https://reactjs.org/docs/hook... 如何利用依赖列表来跳过effect
3.结尾还有一大段note,非常有用
总结:可以忽略,前提是你能准确的保证每个effect都在准确的实际被执行。