I am new to using response.js and trying to write a reusable component that has an optional property passed to it. In the component, this optional property retrieves data from db using a meteorite, then I want to check if the property exists on the returned object (parent_task exists in the task), and if it exists, it adds a link. It seems pretty simple, but I get errors all the time. Does anyone have any suggestions on what I might lose? Is there any jsx gotcha that I am missing?
<Header task={params.task_id} />
Header = React.createClass({
mixins: [ReactMeteorData],
getMeteorData() {
var handle = Meteor.subscribe('tasks');
return {
taskLoading: ! handle.ready(),
task: Tasks.findOne({_id: this.props.task})
}
},
getParentTaskLink() {
if (!this.data.taskLoading) {
var current_task = this.data.task;
if (parent_task in current_task) {
console.log("parent_task exists!");
}
}
},
render() {
return (
<div className="bar bar-header bar-calm">
{this.getParentTaskLink()} // eventually return anchor element here
<h1 className="title">Hello World</h1>
</div>
)
}
});
source
share