Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import countries from '../../countries.json'
- function CountryDetail (props) {
- const findCountry = (name) => {
- return countries.find( country =>{
- return country.name.common === name
- })
- }
- const { params } = props.match
- const theCountry = findCountry(params.name)
- const theCountryName = theCountry.name.common
- const theCountryCapital = theCountry.capital[0]
- return(
- <div>
- <p>{ theCountryName }</p>
- <p>{ theCountryCapital }</p>
- </div>
- )
- }
- export default CountryDetail;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement