I am working with the following function:
extractCountries: function() {
var newLocales = [];
_.forEach(this.props.countries, function(locale) {
var monthTemp = Utils.thisMonthTemp(parseFloat(locale["name"]["temperature"]));
if(parseFloat(locale["name"]["safety"]) > this.state.minSafety &&
parseFloat(locale["name"]["nature"]) > this.state.minNature &&
this.state.weather.min <= monthTemp &&
monthTemp <= this.state.weather.max) {
newLocales.push(locale);
}
}).bind(this);
return newLocales;
}
When I reach the line
parseFloat(locale["name"]["safety"]) > this.state.minSafety &&
, an error is thrown:
Uncaught TypeError: Cannot read property 'state' of undefined
Even though I have already bound the external React object using:
}).bind(this);
What could be the reason behind this error?