DEV Community

loading...

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

Collapse
nicomartin profile image
Nico Martin Author

The benefint is that you decouple logic (fetch) from render view.
I mean it's perfectly fine to call an api right inside your component and write the state-logic there as well. But decoupling makes it cleaner in my oppinion.
Especially if you then need to write unit tests you will benefit from this flexibility.