Skip to content

Conversation

@OrYossef
Copy link

@OrYossef OrYossef commented Jan 3, 2025

done API

@OrYossef OrYossef requested a review from GilHeller January 3, 2025 19:19
Copy link
Member

@Tamir198 Tamir198 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work overall.

Some general notes :

When you have hardcoded strings extract them into constants file


const Country = () => {
const Country = ({ name, flag, population, region, capital, onClick }) => {
return (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work on destruct the props, by doing this you are flattening your data and sending the most simple props to your componenet

</button>
<h2>{country.name}</h2>
<img src={country.flag} alt={`Flag of ${country.name}`} />
<p><strong>Population:</strong> {country.population.toLocaleString()}</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In here you better destruct your props as well

<p><strong>Population:</strong> {country.population.toLocaleString()}</p>
<p><strong>Region:</strong> {country.region}</p>
<p><strong>Capital:</strong> {country.capital}</p>
<p><strong>Subregion:</strong> {country.additionalInfo.subregion}</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing, do not use the strong tag, use css instead

const fetchCountries = async () => {
try {
const response = await fetch("https://restcountries.com/v3.1/all");
const data = await response.json();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Save the hardcoded string into constants, and the fetch function should be extracted to a service that handles api requests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants