DEV Community

Discussion on: 8 Awesome React Hooks

Collapse
 
sunflower profile image
sunflowerseed

I think I would break the loading out of res.response in useFetch().
Why? Because if you load something else (a different URL), then res.response already exists and won't cause the "loading..." to be shown... so the loading flag really needs to be before the start of fetch() and after setData()