non-basic cases are if you have to bring the response data into a global store (i.e. redux), or implement caching, or web sockets or other niche things like that.
This is how Dan Abramov suggests it's done in his article, in which you can observe the fetchData function is defined and invoked inside the useEffect. And the state setter function is called within the fetchData function.
That flavio copes article that theorizable linked to is far too simplistic to help, IMO.
-27
u/StoneColdJane Jun 08 '21
You understund hooks? There is 11k word article explaining useEffect, nobody understund hooks.