简体   繁体   English

未被捕获的TypeError:DB.find不是React with Meteor 1.3中的函数

[英]Uncaught TypeError: DB.find is not a function in React with Meteor 1.3

I'm using Meteor 1.3 with React and I got this error. 我在React上使用Meteor 1.3,但出现此错误。 If I use the console in the browser everything works perfectly. 如果我在浏览器中使用控制台,则一切正常。

 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> ) } } 

and I got this error message: 我收到此错误消息:

  Uncaught TypeError: Tools.find is not a function tools @ Tools.jsx:25render @ Tools.jsx:35(anonymous function) 

Tools is a React component in your code. Tools是代码中的React组件。 find should be used on collections, not on React components. find应该用于集合,而不是React组件。 You'll need to define a Meteor.Collection . 您需要定义一个Meteor.Collection

See the example code here: https://github.com/ultimatejs/tracker-react 在此处查看示例代码: https : //github.com/ultimatejs/tracker-react

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM