Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import React from 'react';
  2. import countries from '../../countries.json'
  3.  
  4. function CountryDetail (props) {
  5.  
  6. const findCountry = (name) => {
  7. return countries.find( country =>{
  8. return country.name.common === name
  9. })
  10. }
  11.  
  12. const { params } = props.match
  13. const theCountry = findCountry(params.name)
  14. const theCountryName = theCountry.name.common
  15. const theCountryCapital = theCountry.capital[0]
  16.  
  17.  
  18. return(
  19. <div>
  20. <p>{ theCountryName }</p>
  21. <p>{ theCountryCapital }</p>
  22. </div>
  23. )
  24.  
  25. }
  26.  
  27.  
  28. export default CountryDetail;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement