React itself doesn’t have any allegiance to any particular way of fetching data. React simply renders components, using data from only two places: props and state. To use some data from the server, you need to get that data into your components’ props or state.
So, How can you make an AJAX call in React?
You have to depend on the Third-party AJAX library.
- You can use the browser
- You can also use jQuery, but it’s not a good decision to include the whole library just for making API calls.
- You hate promises but love callback then you can use superagent
Where to make an AJAX request?
You should populate data with AJAX calls in the
componentDidMount lifecycle method.
Check the official website for more details