https://memory-card-ehz.pages.dev/
This project exercise, created by The Odin Project, is a simple memory card game to practice working with hooks to manage state and side effects while fetching and using data from an API.
Demo:
This is a simple memory card game that tests your ability to remember and select different cards each round. To play, click on a card that has not been selected yet. If your memory serves you right, the cards will shuffle and you get to play again until all 8 cards are selected. If you select a previously selected card, the game ends!
Congratulations! To start a new game, choose any of the two options:
- Refresh the page.
- Click on any card.
Both methods will reset the round and scoreboard as well as display new cards.
When you click on a card that has already been selected, the cards will shuffle and both the round number and current score will reset to their default value. The cards remain the same until you select all 8 cards! To continue playing, click on any card and try and beat your best score.
After completing this project, I found myself getting the hang of working in a React environment and using state and effect hooks. This is only my second time working with APIs, so I learned more about using try/catch
blocks and the process of retrieving data that may or may not contain null/undefined
values. It's important to consider that some data is sparse. Although this is my second time working with APIs, it is my first project working with APIs in React. I implemented the AbortController
Web API to handle React's strict mode from producing multiple API calls. My research at the time led me to believe this was an effective solution, but I may find another solution as I progress through the React curriculum. Moving forward, I definitely plan to look into creating my own custom hooks and components to create cleaner code. This was not a major objective for this project since I am still getting used to working with React and the React workflow.
- Favicon icon by Vitaly Gorbachev on Freepik
- Animal Crossing background image by jotaauvei on DeviantArt
- Amiibo API by Nevin Vu