Skip to content

Instantly share code, notes, and snippets.

@Prtfw
Created June 29, 2017 17:37
Show Gist options
  • Save Prtfw/4e4b52f5c9a3e5ad327fe5fae2e71c4a to your computer and use it in GitHub Desktop.
Save Prtfw/4e4b52f5c9a3e5ad327fe5fae2e71c4a to your computer and use it in GitHub Desktop.
some questions re: stateful compo and how to approach building one
const API_KEY = '5cc1f25759881907aed6171543839b19';
function getWeather() {
return fetch(`http://api.openweathermap.org/data/2.5/weather?id=6167865&appid=${API_KEY}&units=metric`)
.then(res => res.json())
.then(reshapeData);
}
function reshapeData() {
}
const Weather = ({ temp, description, icon }) => (
<div className="bw2 ba blue dib pa3 bg-washed-blue">
<div className="flex items-stretch mb2">
<img src={icon} />
<header className="ml3">
<h1 className="f7 ttu tracked mt0 mb2 flex-auto dark-blue">Toronto</h1>
<p className="f3 mv0">{ temp } ℃</p>
</header>
</div>
<p className="mv0 f5 ttc">{ description }</p>
</div>
);
const App = () => (
<Weather
temp={14.85}
description="proximity shower rain"
icon="http://openweathermap.org/img/w/10d.png"
/>
);
ReactDOM.render(<App />, document.getElementById('exercise'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment