This project is designed to help you practice building a React component that fetches and displays data from an external API. It's a hands-on way to get comfortable with using hooks such as useState
and useEffect
, managing asynchronous operations with async/await
, and handling loading and error states in a React application.
Your task is to create a UserData
component that:
- Fetches user data from the following API endpoint:
https://jsonplaceholder.typicode.com/users/1
- Displays the user's name and email
- Properly handles loading and error states
- Use functional components and React hooks.
- Implement the fetching of data within
useEffect
to ensure it's done when the component mounts. - Use
async/await
for the fetch operation. - Manage the state of the user data, loading status, and any potential errors with
useState
. - Ensure your component is reusable and well-structured.
- Clone this repository to your local machine.
- Navigate to the project directory and install dependencies: