I am trying to modify the image source when it focuses. This is how I fill my annotation array, and you can see my onFocus
event where I try to re-set the annotation to a new image. I am trying to not load the image until the annotation is open.
for(i = 0; i < data.length; i++){
this.state.annotations.push({
longitude: Number(data[i].lng),
latitude: Number(data[i].lat),
title: data[i].loc_str,
focused: false,
onFocus: () => {
this.state.annotations[i].detailCalloutView =
<Image
source={{uri: "http://i.imgur.com/6zc8Apn.jpg", cache: 'force-cache'}}
style={styles.thumbnail}
resizeMode={Image.resizeMode.contain}
/>
},
detailCalloutView:
<Image
source={require('./placeholder.png')}
style={styles.thumbnail}
resizeMode={Image.resizeMode.contain}
/>,
})
}
this.setState({
annotations: this.state.annotations,
});
Error:
undefined is not an object (evaluating 'data[i].img_url')