我有一个useEffect,我只想在React组件中第一次执行它。我在useEffect中使用的是useEffect,如果我将数组依赖项保持为空,就会得到以下警告:
React Hook useEffect has a missing dependency: 'location.pathnameEither include it or remove the dependency array.eslintreact-hooks/exh
使用Reactive16.8.6(在以前的16.8.3版本中很好),当我试图阻止获取请求上的无限循环时,我会得到这个错误:Line 51: React Hook useEffect has a missing dependency: 'fetchBusinessesEither include it or remove the dependency array react-hooks
如果我想只在state1改变时运行效果,但在useEFfect回调中使用了state2的值,我如何解决数组依赖的问题? // do some async logic using a }, [state1]); //Here eslint reacthooks rule requests adding state2 to the dependency array!