Home›Community›How do you fetch API data using React?
How do you fetch API data using React?
amit •
Jul 18, 2026 •
13 views
I want to fetch data from a REST API in React. What is the recommended approach using fetch() or Axios along with useEffect? Please provide a complete example including loading and error handling.
0
1 Answers
yash
Jul 18, 2026
Functional components are JavaScript functions that return JSX and use Hooks such as useState and useEffect to manage state and side effects. Class components are ES6 classes that extend React.Component and use lifecycle methods like componentDidMount and componentDidUpdate. Functional components are simpler, require less code, and are the recommended approach for modern React development because Hooks provide all the features previously available only in class components.