Design comparison
Solution retrospective
I Used React Router for this one, I couldn't get the borders to work, if any one has any advice, I would appreciate it. Thank you.
Community feedback
- @Saad-HishamPosted over 1 year ago
{country.borders!=undefined ? country.borders.map((x,key)=>{ return <span className='border-country'key={x}> {x}</span> }) :null}</span></div>
This code can help you retrieve the borders of a country. However, some countries may not have any borders, in which case the API may return an undefined value. To address this, you can add an if condition to check whether the country has borders. If the condition is true, you can use the map method to loop over the borders. Otherwise, you can return null. Please let me know if this is helpful.
0@CarlPericles18Posted over 1 year agoThank you for your post, however, I am trying to where you clicked the border and it links to whichever country. I am looking for a way to do it using REACT Router. And also a way to where the country name is showed instead of the alphaCode used in the api@Saad-Hisham
0
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