代码如下
./src/views/Login.jsx
Line 12:9: The 'login' function makes the dependencies of useCallback Hook (at line 18) change on every render. Move it inside the useCallback callback. Alternatively, wrap the 'login' definition into its own useCallback() Hook react-hooks/exhaustive-deps
Line 13:9: The 'setUserLoginState' function makes the dependencies of useEffect Hook (at line 24) change on every render. Move it inside the useEffect callback. Alternatively, wrap the 'setUserLoginState' definition into its own useCallback() Hook react-hooks/exhaustive-deps
在 usecallBack 和 useEffect redux action,不把方法引入数组后面 就会报第一个警告,如果把方法引入进去又会报第二个警告,这个该怎么处理?第一次用hooks
login setUserLoginState两个函数每次都是新定义的,会导致下面的onsubmit和useEffect每次render重新执行,把这俩也加上useCallback就行了。。你看下警告的具体内容啊。。