Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Github User Search App w/React

#accessibility#bem#react#fetch
P
Mina Makhlouf• 770

@Minamakhlouf

Desktop design screenshot for the GitHub user search app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
  • API
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


Problem #1: Getting the users preferred color scheme to work in all browsers

I was able to get the users preferred color scheme with the userMediaQuery hook const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)')

However, I found that this would not work on all browsers. It worked on Firefox but was inconsistent on Chrome. I learned that sometimes outside forces can effect this like Operating System Dark Mode, Web Page issues, Browser compatibility or Operating system compatibility.

If someone had better success than me with this issue using React, I would appreciate the advice.

Problem #2: The GitHub API does not reject a fetch request even if there is an error. It will respond to it and in the response body it will say "response.ok = false".

I had a difficult time understanding this and resolving this but what I ended up doing is checking if (!response.ok) { throw new Error(`HTTP Error! status ${response.status}) }

It looks like this: if (!response.ok) { throw new Error(HTTP Error! status ${response.status}); }

What this taught me is that you have to read the API documentation because not all APIs respond to Promises like you expect them to.

Aside from that, if there is any other feedback or help, it would be greatly appreciated.

Community feedback

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord