When

We know how and where to fetch data, but when do we need to do that? It’s obvious that we need to do that as early as possible, so it would be the first place where we know what data we need to ask for. What options do we have:

componentDidMount

componentWillMount

Those are the most popular lifecycle hooks for working with side-effects. You need to check what’s the difference between those two hooks, but we’re using componentDidMount at @unicorndev but it’s another story.

End

This is one of the most common problems nowadays in software development. People try to solve it in different ways, some try to fetch all data on the server side, some use query languages to reduce the amount of data so it can be fetched faster. I hope this article gave you an idea of how to fetch data and how to do it as fast as possible.

What else? If you’re learning React then you might like these articles as well:

Please like & share. Peace.