Incorporating Shimmer Effect in Project

Aug 23, 2024

Lecture Notes for the Countries Project

Project Progress

  • Data fetching successfully completed.
  • Set functionality implemented.
  • Some tasks are still pending:
    • Implement dark mode and light mode.
    • Filter by region.
    • Apply shimmer effect.

Importance of Shimmer Effect

  • Shimmer Effect: Display a gray color blank card until the data arrives.
  • Also known as skeleton loading or loading effect.
  • Indicates to the user that some cards will appear here.

Current Status

  • List of all countries is being displayed.
  • Clicking on any country shows its details.
  • The back button is functioning correctly.
  • Displays blank for a second when the user arrives.

Example of YouTube

  • When we search on YouTube, an initial gray color loading effect is shown.
  • It is not an exact representation but provides clarity to the user.

How to Create Shimmer Effect

  1. Create a Component:
    • Create a file named countriesListShimmer.jsx.
  2. Use Countries Container:
    • Use the countriesContainer class.
  3. Set Card Height:
    • Set the card height to 350 pixels.
  4. Set Background Color:
    • Set the background color to gray.
  5. Conditional Rendering:
    • If countriesData.length is 0, show the shimmer component; otherwise, show country data.

Looping and Rendering

  • Use map() and array.from() for looping in React.
  • Duplicate cards are not needed for higher values.
  • Use new Array(length) to create an empty array.
  • Loop through 10 or 100 cards as an example.

Next Assignment

  • Create countriesDetailShimmer.jsx component.
  • Display shimmer effect during loading.

Future Plan

  • Enable dark mode and light mode in the next video.
  • Studying the Context API for the app is necessary.

Questions and Answers

  • If you have any questions or doubts, ask in the comments.
  • You can also join the Telegram group.

Note: Understand all the main points and tasks thoroughly and work on the project.