Latest solutions
Project - Countries Info on React (with Redux & Styled components)
#axios#react#redux#styled-components#react-routerSubmitted over 1 year agoProject - Countries Info on React and React Router
#react#react-router#sass/scss#webpackSubmitted almost 2 years ago
Latest comments
- @syntaCorpSubmitted almost 2 years ago@Bjorn86Posted almost 2 years ago
According to your question, I implemented it this way: a request to the API for all cards is made when the App is mounted with
useEffect
hook. The cards are recorded in the state and also sent to the component for detailed card display. And in this component a specific card is already determined (also when mounting the component usinguseEffect
hook), in my case I usedcca3
code to search for the card in the array of all cards, it is also used for the url of the child route. This way you can not only save the page when you restart the browser, but you can also access it via a direct link. You can see my implementation and code here.P.S. Forgive my poor English )
Marked as helpful0 - @BGabrieliusSubmitted almost 2 years ago@Bjorn86Posted almost 2 years ago
Hi, good work! If the
formatPopulation
function is to be found in many places, maybe the good old takeaway of the function in utils.js would not be a bad solution? By the way, I used a different approach in my work, namelyIntel.NumberFormat
, it useslocales
. This way we do not do any unnecessary manipulation with the data, and the user gets a number with separators, as it is common in his region. Take a closer look, you may like this method as well. Example:new Intl.NumberFormat().format(card.population)
P.S. Forgive my poor English )
Marked as helpful1