react_jwt_auth icon indicating copy to clipboard operation
react_jwt_auth copied to clipboard

Users.js: useEffect's dependency list should contain: axiosPrivate, location, navigate (or be removed)

Open StefanoOcchetti opened this issue 2 years ago • 3 comments

The useEffect's dependency list in Users.js should contain: axiosPrivate, location, navigate (or be removed)

StefanoOcchetti avatar Jun 24 '22 09:06 StefanoOcchetti

You must be reading that warning from the console. We only want the useEffect hook to run when the component loads, so we leave the dependency array empty. If the console warning bothers you, put this on the line above the useEffect dependency array: // eslint-disable-next-line

On Fri, Jun 24, 2022 at 4:25 AM Stefano Occhetti @.***> wrote:

The useEffect's dependency list in Users.js should contain: axiosPrivate, location, navigate (or be removed)

— Reply to this email directly, view it on GitHub https://github.com/gitdagray/react_jwt_auth/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHRWJN352ZX6YTD4JB4JCMDVQV5KBANCNFSM5ZXHPWYA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

gitdagray avatar Jun 26 '22 15:06 gitdagray

Drastically removing the dependency list fixes the warning. That is, at line 34: replace:

 }, [])

with:

 })

StefanoOcchetti avatar Jun 27 '22 07:06 StefanoOcchetti

There is a difference in providing no dependency array and providing an empty one: https://stackoverflow.com/questions/58579426/in-useeffect-whats-the-difference-between-providing-no-dependency-array-and-an

On Mon, Jun 27, 2022 at 2:11 AM Stefano Occhetti @.***> wrote:

Drastically removing the dependency list fixes the warning. That is, at line 34: replace:

}, [])

with:

})

— Reply to this email directly, view it on GitHub https://github.com/gitdagray/react_jwt_auth/issues/2#issuecomment-1166967938, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHRWJN2VORVJGY6RD5ZFSCTVRFH2LANCNFSM5ZXHPWYA . You are receiving this because you commented.Message ID: @.***>

gitdagray avatar Jun 28 '22 23:06 gitdagray