Responsive Countries using React Router for paths and React JS
Design comparison
Solution retrospective
There is a small bug that I couldn't fix, it's related to the React Router when you are trying to go to another path, example: /name/:name to /code/:code , react doesn't Re Render when doing this, so it won't display the content, if you refresh it will work.
Community feedback
- @markuslewinPosted about 2 years ago
This comment was deleted about 2 years ago
1@EnzCamposPosted about 2 years ago@markuslewin Thank you, although that didn't outright fix it, it helped solved the issue, it was trying to map over the Countries before it had any data, the solution was to change the code to the restCountriesUrl and to make an onClick handler on the a tag to set the state to undefined, thus rendering the page loading element instead of throwing an error.
<a href={`/Countries-Rest-API/#/code/${elem}`} ` key={elem} className={`border-country-link ${dark}`} onClick={()=>{setCountryData()}}>{elem} </a>```
1
Please log in to post a comment
Log in with GitHubJoin 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