-
Notifications
You must be signed in to change notification settings - Fork 22
Converted Projcet to React #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Tamir198
left a comment
There was a problem hiding this 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
src/components/Country.jsx
Outdated
| const Country = () => { | ||
| const Country = ({ country }) => { | ||
| return ( | ||
| // TODO: Country component |
There was a problem hiding this comment.
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>
);
};
src/components/Filters.jsx
Outdated
| <div className="dropdown-body"> | ||
| <ul> | ||
| <ul> | ||
| <li data-region="all" onClick={onRegionChanged}> |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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
No description provided.