
From A Career In Logic Gates to React with Evan Walter
The React Show
00:00
Use Effect to Fetch Data From an API
I think what I see a lot is people that are trying to do too complicated of stuff with it. You know, a common example I've talked about a lot is you'll have a component that needs to fetch some data from an API and display it. So naturally people put that in, use effect to fetch that data, right? And that's where you start getting into lots of issues. Whereas the right way to fetch data is probably to fetch it on the action that leads to the data being needed. When you hit the submit button, you know you need to fetch the data. You should be fetching it then. But it's one of those things where it just feels natural
Transcript
Play full episode