This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// useWeatherService.js | |
import { useState, useEffect } from 'react'; | |
import keys from './keys'; | |
const apiKey = keys.openweather; | |
const useWeatherService = (coords, unit) => { | |
const [weather, setWeather] = useState(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// App.js | |
... | |
import { useWeatherService } from './useWeatherService'; | |
const [ currentUnit, setUnit ] = useState(TEMPERATURE_UNITS.metric); | |
function App({coords}) { | |
const weather = useWeatherService(coords, currentUnit); // <- all that's left of the API logic :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rateMyDay(decimal) { | |
const ratingInWords = decimal > 0.5 ? 'great!' : 'eh.'; | |
return [[decimal, ratingInWords], [decimal, ratingInWords]]; | |
} |
OlderNewer