This is a solution to the REST Countries API with color theme switcher challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- See all countries from the API on the homepage
- Search for a country using an
input
field - Filter countries by region
- Click on a country to see more detailed information on a separate page
- Click through to the border countries on the detail page
- Toggle the color scheme between light and dark mode (optional)
I learned A LOT by coding this project. At first, I thought that using an API was only about fetching it and displaying the contents, as easily as displaying objects in Django, for instance. I was incredibly wrong.
Unlike my other API solutions posted in Frontend Mentor (as is. I may fix them later), this one doesn't have any hydration problems whatsoever. I learned to use the React hook useEffect in order to properly fetch and render the objects with no hydration problems.
I also used, for the first time ever (on an actual project), the .filter() function. Implementing the search function was actually my biggest problem.
This was my first time implementing a theme changer (to toggle light/dark mode). Please check useful resources to learn how I did it.
- How to Create a Dark Mode in Sass
- Ekaterine Mitagvaria's code
- Client-side data fetching with useEffect
- Github - daniel-web-developer
- Frontend Mentor - @daniel-web-developer
I'd like to point out that my code was loosely inspired on Ekaterine Mitagvaria's solution (live site, Frontend Mentor solution and code).