我正在使用Meteor 1.3和React,我收到了这个错误。如果我在浏览器中使用控制台,一切都很完美。
var url = "..."
$.getJSON(url, function(data) {
var data = jQuery.parseJSON(JSON.stringify(data));
var i;
for (i=0; i<5; i++)
{
$("#div").append(data.data.temp[i]);
}
});
}
我收到了此错误消息:
import React, {Component} from 'react';
import TrackerReact from 'meteor/ultimatejs:tracker-react';
import ToolsForm from './ToolsForm.jsx';
import ToolsCards from './ToolsCards.jsx';
export default class Tools extends TrackerReact(Component) {
constructor(){
super();
this.state = {
subscriptions: {
tools: Meteor.subscribe('allTools')
}
}
}
componentWillUnmount() {
this.state.subscriptions.tools.stop();
}
tools() {
return Tools.find().fetch();
}
render() {
return (
<div>
<ToolsForm /> <br/><br/>
<ul className="resolutions">
{this.tools().map( (tool)=> {
return <ToolsCards key={tool._id} tool={tool} />
})}
</ul>
</div>
)
}
}
答案 0 :(得分:0)
Tools
is a React component in your code. find
should be used on collections, not on React components. You'll need to define a Meteor.Collection
.
See the example code here: https://github.com/ultimatejs/tracker-react