I have a component that has a subscription to items.
The items are confirmed to be there as if I use the following it returns the cursor with the item inside it:
console.log(Items.find({key: itemKey}).fetch());
The items collection is imported etc.
My constructor:
constructor(){
super();
this.state = {
subscription: {
items: Meteor.subscribe("allItems")
}
}
}
my component will unmount method:
componentWillUnmount(){
this.state.subscription.items.stop();
}
This is the methods where the issue lies. The error is Uncaught TypeError: Cannot read property ‘srcEntire’ of undefined:
getItemSource(itemKey){
console.log(itemKey); // shows the correct key
var itemer = Items.findOne({key: itemKey});
console.log(itemer.srcEntire);
return itemer.srcEntire;
}
The render section ( It shows the image if I hardcode the return value of the getItemSource method. The source of the image is found by calling the getItemSource method and passing in the layer prop that is passed in (props work):
render(){
return (
<div className="col-lg-3" >
<img id="myLayer" className="on-top img-responsive center-block on-top " name="myLayer" src={this.getItemSource(this.props.layers.myLayer)} />
</div>
)}