I am using js reaction and in my next code I get an error Uncaught TypeError: Cannot read property 'getHostNode' of null. I referred to this link. But this is not useful in my case. Below is my code:
for(var i=0;i<city.length;i++){
if(city[i]!= null){
if(i < 10){
cityListValues.push(<li key={"city-"+i} ><a onClick={this.updateCity} id={city[i].city_id} className={(this.props.city_name==city[i].name)? 'active':''}>{city[i].name}</a></li>);
} else{
break;
}
}
}
When I click on a tag, the first time it works fine. But the next time he always throws a mistake. I can’t understand what the problem is. When the method is called, it displays about 5 components and sets the state for them. I applied the indicated solution there and pasted all the text inside span, but still I keep getting the error.
City data: [{"city_id":202,"name":"abc","no_of_activities":1},{"city_id":175,"name":"xyz","no_of_activities":13},{"city_id":4612,"name":"pqr","no_of_activities":1},{"city_id":3,"name":"a1s2","no_of_activities":83},{"city_id":176,"name":"fgj","no_of_activities":1},{"city_id":172,"name":"ytu","no_of_activities":2},{"city_id":1092,"name":"mkju","no_of_activities":1}]
updateCity : function() {
var iso_code = '/';
this.props.changeCity(event.target.id);
if(this.props.country_id !== '99') {
for (var i=0; i<this.props.country_list.length; i++) {
if(this.props.country_id == this.props.country_list[i].country_id) {
iso_code = '/'+this.props.country_list[i].iso_code_2.toLowerCase()+'/';
}
}
}
browserHistory.push(iso_code);
},