DEV Community

Discussion on: the correct way to fetch data with react hooks

Collapse
 
rvasquez profile image
Rogger Vasquez

Hello @nicomartin , thanks a lot for sharing this, I loved this approach.

However I noticed that implementing this will give a linter rule error for react-hooks/exhaustive-deps because the UseEffect will depend on external data: url and SetPartData.

So I moved the SetPartData inside the UseEffect hook, put url in the dependency array (It will not change so I don't see a problem here) and made a functional update for the setData()

Please let me know what you think about this (I also made some renaming having in count the advice @targumon shared):

github.com/r-vasquez/React_mock_re...