From 1fcde6a4edb51c98fde0b6c0ed5eb7232c6ec30a Mon Sep 17 00:00:00 2001 From: Barranger Ridler Date: Wed, 26 Aug 2020 20:46:50 -0400 Subject: [PATCH] it turns out that forecast has an e, who'd a thunk it --- App.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/App.js b/App.js index ff872e3..7262ac5 100644 --- a/App.js +++ b/App.js @@ -6,26 +6,26 @@ const url = `https://api.openweathermap.org/data/2.5/onecall?lat=43.379100&lon=- const App = () => { - const [forcast, setForcast] = useState(null); + const [forecast, setForecast] = useState(null); useEffect(() => { - const loadForcast = async () => { - if (!forcast) { + const loadForecast = async () => { + if (!forecast) { var response = await fetch(url); var data = await response.json(); - setForcast(data); + setForecast(data); } } - loadForcast(); + loadForecast(); }) - if (!forcast) { + if (!forecast) { return ; } - const current = forcast.current.weather[0]; + const current = forecast.current.weather[0]; // TODO: In an upcoming blog post, I'll be extracting components out of this class as you would in a real application. return ( @@ -38,14 +38,14 @@ const App = () => { uri: `http://openweathermap.org/img/wn/${current.icon}@4x.png`, }} /> - {Math.round(forcast.current.temp)}°C + {Math.round(forecast.current.temp)}°C {current.description} - Hourly Forcast + Hourly Forecast index.toString()} renderItem={(hour) => { const weather = hour.item.weather[0]; @@ -66,7 +66,7 @@ const App = () => { Next 5 Days - {forcast.daily.slice(0,5).map(d => { //Only want the next 5 days + {forecast.daily.slice(0,5).map(d => { //Only want the next 5 days const weather = d.weather[0]; var dt = new Date(d.dt * 1000); return