var React = require('react'); var WeatherForm = require('WeatherForm'); var WeatherMessage = require('WeatherMessage'); var openWeatherMap = require('openWeatherMap'); var Weather = React.createClass({ getInitialState: function () { return { isLoading: false } }, handleSearch: function (location) { var that = this; this.setState({isLoading: true}); openWeatherMap.getTemp(location).then(function (temp) { that.setState({ location: location, temp: temp, isLoading: false }); }, function (errorMessage) { that.setState({isLoading: false}); alert(errorMessage); }); }, render: function () { var {isLoading, temp, location} = this.state; function renderMessage () { if (isLoading) { return

Fetching weather...

; } else if (temp && location) { return ; } } return (

Weather Component

{renderMessage()}
) } }); module.exports = Weather;