【发布时间】:2017-06-04 04:13:33
【问题描述】:
好吧,我不知所措。编写 Meteor React 应用程序......它创建了一个集合并仍然执行该部分。我最近上传了一个货币格式化程序:来自 npm 的 react-currency-input ,它完成了我想要的操作并写入了 mongo db,我可以从终端毫无问题地访问它。
但是在运行我的应用程序时,它给了我两个新的崩溃原因,我不知道为什么:
- 警告:通过主 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();
}
有没有人知道我可以从哪里开始调试,或者为什么我突然发现这些新错误?
【问题讨论】:
-
我要检查的第一件事是您是否正确导入了门票集合。
-
其实那是个好地方!谢谢。
-
但它仍然给我错误