
Design comparison
Solution retrospective
making a custom hook and implementing some new things in my code such as modal component and forwardRef and many other things I don't remember TBH.
What challenges did you encounter, and how did you overcome them?Opening the modal using context api was a pain but i cancelled that idea as the code didn't work asynchronously so i went back to prop drilling (well it's not prob drilling because i passed the functions to one component only) and i was gonna use useReducer instead of useState but the state updating functions was not complicated so I canceled that idea.
What specific areas of your project would you like help with?Any feedback is appreciated
Please log in to post a comment
Log in with GitHubCommunity feedback
- @GADMuhammad
1- When a country is open, make the background blur. to not make the user get confused.
2- It should close when pressing outside the country modal (pop-up).
3- On every country page, border countries should be buttons to open this border-country page. Not <li>s inside <ul>
4- The country page modal should be gone with animation like it appears with animation. Not immediately.
4- On the list of continents in the light mode, when I hover an option, its background should be more obvious, not that light.
5- The option of "reset" should be called "All countries".
6- The placeholder of the input should be lighter.
7- When I click outside the list of continents, it should close. The same as the modal.
Marked as helpful - @ippotheboxer
Hey there, nice solution!
First of all, you mentioned how using a modal was complicated: a modal is brought up when pressing on a country, but I think it would indeed be less complicated if you used react-router and instead took the user to a new page (e.g. /:countryName) when they press on a country, and then fetch the country name using useParams and then hitting up the API.
Also, searching for a country doesn't work when a filter is applied. This is because you have done it like this:
if (filterRegion) { FILTERED_COUNTRIES = countries.filter( (country) => country.region === filterRegion ); } else if (searchRegion) { FILTERED_COUNTRIES = countries.filter((country) => country.name.common .toLowerCase() .includes(searchRegion.toLowerCase().trim()) );}
Filtered region takes precedence over the search, so search will only work if there is no filter. Here is how you can do it so that both work:
let FILTERED_COUNTRIES = countries; if (filterRegion) { FILTERED_COUNTRIES = FILTERED_COUNTRIES.filter( (country) => country.region === filterRegion ); } if (searchRegion) { FILTERED_COUNTRIES = FILTERED_COUNTRIES.filter((country) => country.name.common.toLowerCase().includes(searchRegion.toLowerCase().trim()) ); }
I see that you have your filter and search context separated, but I feel like it's fine to have them both together in context, since they are both directly manipulating the countries that are being shown
Marked as helpful
Join 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