Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 3 years ago

React REST Countries & Weather API with color theme switcher

fetch, react, react-router, styled-components, node
Travolgi 🍕•31,320
@denielden
A solution to the REST Countries API with color theme switcher challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Hi there :)

I had a lot of fun in this challenge and had a good opportunity to learn how to use Router v6 and Styled Components for the first time.

Also I practiced a lot with React custom hooks, initially I had some problems in the details page because React didn't update the page content because I rightly didn't set the listening on the parameter that changed.

Also I added some additional features:

  • See current country weather data on detail page through other API
  • See the Map of the country on the details page
  • Button scroll to top after the scrool
  • Button for query reset when typing on the search input
  • Error page with animated svg when no results found
  • LocalStorage save of the set light or dark mode theme

But...

  • Despite my extensive research I still have to figure out how I can create a preload at render time while react builds the page so that the "hops" due to reset.css are not seen as soon as the app is opened.
  • I also want to understand how to show an upload on the single image as it is uploaded.

Thank you for taking the time to check out my project! And Happy coding ;)

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Isaac Novaes•650
    @isaacnovaes
    Posted about 3 years ago

    Hey @danielden!

    Great job! Your solution looks great. Also, the idea of displaying the country's weather and localization is awesome. However, I have a few suggestions:

    • If I go to any country detail and reload the page, your website crashes. I think that you should look into it
    • For a tablet dimension, for example, 811 x 860, all border country buttons are stacked in a column, leaving too much space which could be better used. So fixing it could improve the UI and the responsiveness
    • If a country has no currencies, nothing is displayed. I think that at least a "no currency" message should be displayed
    • If a country has no border, like Antarctica, a UI button with "no countries" text is displayed. I think that only a simple text fits best here instead of a UI button because, in this border countries section, a button links you to another country
    Marked as helpful
  • Kevin Mason•280
    @mrfinesse47
    Posted about 3 years ago

    hello,

    good job on this project especially with the maps and weather additions. one thing i noticed is that some of the buttons such as "back" don't change the cursor to pointer. The Neighbour countries buttons only work when you click on the text but not anywhere else on the button. I also think the drop down items can use some more styling to be more inline with the design documentation. I really liked the loading transition, and custom slider. You have lots of neat extra additions.

    Marked as helpful
  • Prabhash Ranjan•2,540
    @besttlookk
    Posted about 3 years ago

    hi, There are few thinks i like to point about: 1.You are making lots of network request, which i think is not required. First duing filtering, You already have data for all the countring filter from that data rather than making a new network request. 2.After visiting detail page, when going to home page again, you made another request, which i think was not required. Just transfer the data fetching logic to "app.js" file that way you data will be save irrespective of the page. 3. To make it even faster you can keep track which country detail info has been fetched and store it. That way if user again open the same page rather than making a new request just used the stored data.

    Here is how i did: https://www.frontendmentor.io/solutions/react-tailwind-scss-context-api-axios-B-76lKa-G

    I also made this using nextJS. which is supe-fast with no refesh as it is a static generated page. https://www.frontendmentor.io/solutions/nextjsstatic-generation-styledcomponets-ht7_ZZF55

    Good luck #happyCoding

    Marked as helpful
  • the prince•30
    @AAHMM
    Posted over 2 years ago

    AMAZING GOOD WORK

  • Hayatunnabi Nabil•130
    @imhayatunnabi
    Posted about 3 years ago

    nice work man !!!!

  • Julian•80
    @julian-GF
    Posted about 3 years ago

    excelent work!

  • Hexer•3,620
    @EmmanuelHexer
    Posted over 3 years ago

    Great work man, Nicely done

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit 1st-party linked stylesheets, and styles within <style> tags.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub