Im using Meteor + React and “this.props.thing.source” is a string for a mongodb _id.
As you can see it works fine when I pass in the string of the ID itself, but I get an undefined error when passing in the variable, even though that variable renders out that same string.
In this code:
Thing = React.createClass({
propTypes: {
thing: React.PropTypes.object.isRequired
},
render() {
return (
<ul>
<li>Display: {Things.findOne(this.props.thing.source).data}</li>
<li>Display: {Things.findOne("emq6M4WbJeRvkA6Q3").data}</li>
<li>Source: {this.props.thing.source}</li>
</ul>
);
}
});
This does NOT work:
Display: {Things.findOne(this.props.thing.source).data}
This works:
Display: {Things.findOne(“emq6M4WbJeRvkA6Q3”).data}
And this correctly renders “emq6M4WbJeRvkA6Q3”:
Source: {this.props.thing.source}
The ERROR I am getting:
“Uncaught TypeError: Cannot read property ‘data’ of undefined”