
var ReactWeather = React.createClass({
  getInitialState: function() {
    return {
      citysArr: [],
      userLocation: 'London'
    };
  },

  componentDidMount: function() {
    this._getCitysFromStorage();

    var self = this;
    self._getCityWeather('London', function(result) {
      if ( self.isMounted() ) {
        self.setState({
          temp: result.main.temp,
          icon: result.weather[0].icon,
          pressure: result.main.pressure,
          humidity: result.main.humidity
        });
      }
    });
  },

  componentWillUnmount: function() {
    this._setCitysToStorage();
  },

  _getCitysFromStorage: function() {
    localStorage['citysArr'] = '{"a":"cbbb"}';
    console.log(JSON.parse(localStorage['citysArr']));
    /*
    this.setState({
      citysArr: JSON.parse(localStorage['citysArr'])
    });
  */
  },

  _setCitysToStorage: function() {
    localStorage['citysArr'] = JSON.stringify(this.state.citysArr);
  },

  _getCityWeather: function(city, cb) {
    var appid = '2de143494c0b295cca9337e1e96b00e0';
    var url = 'http://api.openweathermap.org/data/2.5/weather';
    
    $.get(url, {q: city, appid: appid}, cb);
  },

  _addCity: function(city) {
    this.setState(function(state) {
      state.citysArr = state.citysArr.push(city);
    });
  },
  
  render: function () {
    var state = this.state;
    var iconLink = 'http://openweathermap.org/img/w/'+state.icon+'.png'
    console.log(state);
    return (
      <div>
        <div><img src={iconLink} /></div>
        <div>
          <span>Влажность: {state.humidity} </span><br/>
          <span>Давление: {state.pressure} </span><br/>
          <span>Температура: {state.temp} </span><br/>
        </div>
      </div>
    );
  }
});

ReactDOM.render(
  <ReactWeather />,
  document.getElementById('ReactWeather')
);

@@ -667,32 +667,34 @@
 nction() %7B%0D%0A    
+//
 localStorage%5B'ci
@@ -693,67 +693,99 @@
 rage
-%5B'citysArr'%5D = '%7B%22a%22:%22cbbb%22%7D';%0D%0A    console.log(JSON.parse(
+.removeItem('citysArr');%0D%0A    if(typeof localStorage%5B'citysArr'%5D === 'undefined') %7B%0D%0A      
 loca
@@ -808,19 +808,25 @@
 rr'%5D
-))
+ = '%5B%5D'
 ;%0D%0A    
-/*
+%7D%0D%0A
 %0D%0A  
@@ -898,16 +898,16 @@
 Arr'%5D)%0D%0A
+
     %7D);%0D
@@ -911,14 +911,8 @@
 );%0D%0A
-  */%0D%0A
   %7D,

fix problem with local storage