Skip to content

Instantly share code, notes, and snippets.

@yonibot
yonibot / app.js
Last active November 18, 2019 19:42
step 3
// useWeatherService.js
import { useState, useEffect } from 'react';
import keys from './keys';
const apiKey = keys.openweather;
const useWeatherService = (coords, unit) => {
const [weather, setWeather] = useState();
@yonibot
yonibot / app.js
Created November 18, 2019 19:27
Consuming the final hook
// 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 :)
@yonibot
yonibot / rate_my_day.js
Created August 13, 2020 21:49
Google Sheets Custom Functions
function rateMyDay(decimal) {
const ratingInWords = decimal > 0.5 ? 'great!' : 'eh.';
return [[decimal, ratingInWords], [decimal, ratingInWords]];
}