Skip to content

Conversation

@adirav02
Copy link

No description provided.

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 , I left you some comments

const Country = () => {
const Country = ({ country }) => {
return (
// TODO: Country component
Copy link
Member

Choose a reason for hiding this comment

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

You can also destruct the country coming from the props directly :

const Country = ({ country: { name, flag, population, region, capital } }) => {
  return (
    <div className="country scale-effect" data-country-name={name}>
      <div className="country-flag">
        <img src={flag} alt={name} />
      </div>
      <div className="country-info">
        <h2 className="country-title">{name}</h2>
        <ul className="country-brief">
          <li>
            <strong>Population: </strong>
            {population}
          </li>
          <li>
            <strong>Region: </strong>
            {region}
          </li>
          <li>
            <strong>Capital: </strong>
            {capital}
          </li>
        </ul>
      </div>
    </div>
  );
};

<div className="dropdown-body">
<ul>
<ul>
<li data-region="all" onClick={onRegionChanged}>
Copy link
Member

Choose a reason for hiding this comment

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

In react when we have some list it is best to render it via the map function :

const regions = [
  { label: "All", value: "all" },
  { label: "Africa", value: "africa" },
  { label: "America", value: "americas" },
  { label: "Asia", value: "asia" },
  { label: "Europe", value: "europe" },
  { label: "Oceania", value: "oceania" },
];

<ul>
  {regions.map((region) => (
    <li
      key={region.value}
      data-region={region.value}
      onClick={onRegionChanged}
    >
      {region.label}
    </li>
  ))}
</ul>

);
// Initialize the state with data from the JSON file
const [countries, setCountries] = useState(CountriesData);
const [selectedRegion, setSelectedRegion] = useState("all");
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that the comment adds a lot, because useState(CountriesData); means exactly what you wrote in your comment

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