Name | Progress |
---|---|
Course outline | Not Read |
Name | Progress |
---|---|
Key Concepts | Not Read |
Project: Pet Parade | Not Read |
Challenge 1 | Not Attempted |
Quiz 1 | Not Attempted |
Name | Progress |
---|---|
Project: Profile Card Creator | Not Read |
Key Concepts | Not Read |
Challenge 2 | Not Attempted |
Quiz 2 | Not Attempted |
Name | Progress |
---|---|
Key Concepts | Not Read |
Project: Magic Garden | Not Read |
Challenge 3 | Not Attempted |
Quiz 3 | Not Attempted |
Name | Progress |
---|---|
Key Concepts | Not Read |
Project: Weather Wardrobe | Not Read |
Challenge 4 | Not Attempted |
Quiz 4 | Not Attempted |
Name | Progress |
---|---|
Key Concepts | Not Read |
Project: "Interactive Quiz App" | Not Read |
Challenge 5 | Not Attempted |
Quiz 5 | Not Attempted |
Name | Progress |
---|---|
Key Concepts | Not Read |
Project: "Registration Form" | Not Read |
Challenge 7 | Not Read |
Quiz 7 | Not Attempted |
Name | Progress |
---|---|
Key Concepts | Not Read |
Project: "Weather Dashboard" | Not Read |
Challenge 8 | Not Attempted |
Quiz 8 | Not Attempted |
Overview:
In this challenge, you will enhance the "Photo Gallery" project by adding a button that loads more photos when clicked. This will help you practice handling state updates, managing lists, and interacting with APIs.
Objective:
Instructions for the Interactive Code Block:
Step 1: Create a Button to Load More Photos
Add a button at the bottom of your photo gallery. This button will be used to load more photos.
Step 2: Define the <strong>handleLoadMore</strong> Function
Create a function called <strong>handleLoadMore</strong> that will be triggered when the button is clicked. This function should fetch more photos from the API and append them to the existing list.
Step 3: Append New Photos to the Existing List
In the <strong>handleLoadMore</strong> function, update the state to include the newly fetched photos along with the existing ones.
Step 4: Test the Load More Functionality
Run your application and test the button to ensure it loads more photos each time it's clicked. Make sure the photos are appended to the existing list without duplication.
Next Steps:
By completing this challenge, you will enhance your Photo Gallery project with dynamic loading functionality, making it more interactive and user-friendly. Enjoy coding and experimenting with your photo gallery!
Step 1 Hint: Place the button inside your component's return statement, below the current list of photos.
// Inside the return statement of PhotoGallery component
<button onClick={handleLoadMore}>Load More Photos</button>
Step 2 Hint: Use the <strong>fetch</strong> method to get more photos and update the state with the new list of photos.