Skip to content

Commit

Permalink
Fix undefined var when moving from loc to country and back to loc. (#108
Browse files Browse the repository at this point in the history
)

Data was not invalidated before the 1st rendering leading to undefined
  • Loading branch information
danielfdsilva authored and olafveerman committed Sep 1, 2016
1 parent 45a630d commit 90cf4eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/assets/scripts/components/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const MapComponent = React.createClass({

locationPageSetup: function () {
let data = _.find(this.props.measurements, {location: this.props.highlightLoc});
if (!data) return;
this.showPopover(data);
this.selectLocationPoint(this.generateFeature(data));
},
Expand Down
15 changes: 8 additions & 7 deletions app/assets/scripts/views/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ var Location = React.createClass({
// Get the measurements.
let toDate = moment.utc();
let fromDate = toDate.clone().subtract(8, 'days');
console.log('loc', loc);
// this.props._fetchLatestMeasurements({city: loc.city, has_geo: 'true'});
this.props._fetchLatestMeasurements({
coordinates: `${loc.coordinates.latitude},${loc.coordinates.longitude}`,
Expand Down Expand Up @@ -206,12 +205,14 @@ var Location = React.createClass({
</div>
<div className='col-sec'>
<p className='heading-alt'>Latest Measurements:</p>
<ul className='measurements-list'>
{locLastMeasurement.measurements.map(o => {
let param = _.find(this.props.parameters, {id: o.parameter});
return <li key={o.parameter}><strong>{param.name}</strong>{o.value}{o.unit} at {moment(o.lastUpdated).format('YYYY/MM/DD HH:mm')}</li>;
})}
</ul>
{locLastMeasurement ? (
<ul className='measurements-list'>
{locLastMeasurement.measurements.map(o => {
let param = _.find(this.props.parameters, {id: o.parameter});
return <li key={o.parameter}><strong>{param.name}</strong>{o.value}{o.unit} at {moment(o.lastUpdated).format('YYYY/MM/DD HH:mm')}</li>;
})}
</ul>
) : <p>N/A</p>}
</div>
</div>
);
Expand Down

0 comments on commit 90cf4eb

Please sign in to comment.