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

REST Countries API using React Styled Components

Riki Wendri 1,380

@F4YY

Desktop design screenshot for the REST Countries API with color theme switcher coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
  • API
4advanced
View challenge

Design comparison


SolutionDesign

Community feedback

Aleksei 200

@AlekseiBestuzhev

Posted

Hello.

  • The countries of the Oceania region (not only them, but in the majority) throw a 400 error when opened.
  • There is no Antarctic in the filter.
  • When I open the country Antarctica, the application crashes.

Otherwise great, keep it up!👍

Marked as helpful

0

Riki Wendri 1,380

@F4YY

Posted

Hi @AlekseiBestuzhev,

Thanks for your keen eyes to see error in my code. I've just resolved it and updated additional code and now it looks fine - searchable, filterable and clickable.

Keep happy coding...

0
Błażej 390

@blazejpak

Posted

Hey, read about window.matchMedia("(prefers-color-scheme:dark)").matches{}

It will automatically check what the prefer scheme you have in options.

const [themeDark, setThemeDark] = React.useState(false);

useEffect(() => {
if (window.matchMedia("(prefers-color-scheme:dark)").matches) {
setThemeDark(true)
} else {
setThemeDark(false)
}
}, []);


//Add dark class to html tag
useEffect(() => {
if (themeDark) {
document.documentElement.classList.add("dark");
} else document.documentElement.classList.remove("dark");
}, [themeDark]);  // 

What's more, since react 18+, you don't have to import React and use for example React.useState()

But to sum up, great work, really.

0

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