From fcfd29853ea1d9a4f9ec5e7c1b214ad6b0a7dbf7 Mon Sep 17 00:00:00 2001 From: Thuan Bui Date: Fri, 3 Sep 2021 07:26:51 +0700 Subject: [PATCH] Completed 2.14 (fix error) --- part2/2.12-2.14/src/App.js | 3 +-- part2/2.12-2.14/src/components/Country.js | 5 ++--- part2/2.12-2.14/src/components/Weather.js | 8 +++++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/part2/2.12-2.14/src/App.js b/part2/2.12-2.14/src/App.js index ca83c2f..e8d73f7 100644 --- a/part2/2.12-2.14/src/App.js +++ b/part2/2.12-2.14/src/App.js @@ -9,7 +9,7 @@ const App = () => { const [CountryList, setCountryList] = useState([]) const [ResultList, setResultList] = useState([]) const [WeatherData, setWeatherdata] = useState([]) - + console.log(WeatherData) useEffect(() => { axios .get('https://restcountries.eu/rest/v2/all') @@ -19,7 +19,6 @@ const App = () => { }, []) useEffect(() => { - console.log(ResultList) if (ResultList.length === 1 ) { const capital = ResultList[0].capital.replace(/\s/g, '+') console.log(capital) diff --git a/part2/2.12-2.14/src/components/Country.js b/part2/2.12-2.14/src/components/Country.js index 2b96245..26228c8 100644 --- a/part2/2.12-2.14/src/components/Country.js +++ b/part2/2.12-2.14/src/components/Country.js @@ -12,6 +12,7 @@ const Country = ({data,onClick,weather}) => { list > 1 ? data.map((item, index) => clickHandler(index)} weather={weather}/>) : data.map(item => ) } + ) @@ -31,8 +32,6 @@ const CountryLongList = ({data, onClick,weather}) => { ); } const CountryDetail = ({data,weather}) => { - console.log("Data", data) - console.log("Length", data.length) return (

{data.name}

@@ -47,7 +46,7 @@ const CountryDetail = ({data,weather}) => { {data.languages.map(item =>
  • {item.name}
  • )} {data.name} - + {weather.length === 0 ? "" : }
    ) } diff --git a/part2/2.12-2.14/src/components/Weather.js b/part2/2.12-2.14/src/components/Weather.js index 194d4c6..31c9571 100644 --- a/part2/2.12-2.14/src/components/Weather.js +++ b/part2/2.12-2.14/src/components/Weather.js @@ -1,10 +1,12 @@ import React from 'react' const Weather = ({weather,capital}) => { + + console.log("Weather:", weather) const {current_condition} = weather - const temperature = current_condition[0].temp_C - const windspeed = current_condition[0].windspeedKmph - const winddirection = current_condition[0].winddir16Point + const temperature = current_condition[0].temp_C || '' + const windspeed = current_condition[0].windspeedKmph || '' + const winddirection = current_condition[0].winddir16Point || '' return (

    Weather in {capital}