【问题标题】:meteor collections db.find() not a function (mid-development)流星集合 db.find() 不是函数(开发中)
【发布时间】:2017-06-04 04:13:33
【问题描述】:

好吧,我不知所措。编写 Meteor React 应用程序......它创建了一个集合并仍然执行该部分。我最近上传了一个货币格式化程序:来自 npm 的 react-currency-input ,它完成了我想要的操作并写入了 mongo db,我可以从终端毫无问题地访问它。

但是在运行我的应用程序时,它给了我两个新的崩溃原因,我不知道为什么:

  1. 警告:通过主 React 包访问 PropTypes 已被弃用。请改用 npm 中的 prop-types 包。

这很奇怪,因为我没有在 react 的任何地方定义 proptypes。

2。 未捕获的 TypeError:Tickets.find 不是函数

错误中引用了这段代码:

export default class TicketList extends React.Component {
  constructor (props) {
      super(props);
      this.state = {
        tickets: []
      };
    }
    componentDidMount() {
      console.log('componentDidMount TicketList');
      this.ticketTracker = Tracker.autorun(() => {
        Meteor.subscribe('tickets');
        let tickets = Tickets.find({}).fetch();
        this.setState({ tickets });
      });
    }
    componentWillUnmount() {
      console.log('componentWillUnmount TicketList');
      this.ticketTracker.stop();
    }

有没有人知道我可以从哪里开始调试,或者为什么我突然发现这些新错误?

【问题讨论】:

  • 我要检查的第一件事是您是否正确导入了门票集合。
  • 其实那是个好地方!谢谢。
  • 但它仍然给我错误

标签: reactjs meteor


【解决方案1】:

是的,正如@John Smith 指出的那样 - 我的票证集合不再是默认导出,因此我必须在导入它的任何位置添加 {},这解决了主要问题。谢谢!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-23
    • 1970-01-01
    • 1970-01-01
    • 2016-07-11
    • 2017-05-12
    • 1970-01-01
    • 2013-11-30
    相关资源
    最近更新 更多