我在我的应用程序中使用了道具,这些道具是通过以下方式获取的:”
export default withTracker(() => {
let custAccounts = Meteor.subscribe('allAccounts');
return {
ready: custAccounts.ready(),
custs: Meteor.users.find({}).fetch()
}
})(Forward);
然后在componentDidmount()中:
componentDidMount(){
if (this.state.isMounted) {
Meteor.call('getCurrentCF', this.props.custs[0].subscriber_id, (err, res) => {
if (!err) {
var result = JSON.parse(res.content);
if (typeof result.cfu['destinations'] != 'undefined') {
if(result.cfu['destinations'][0].destination === "voicebox") {
this.setState({
cfActive: 'btn btn-block btn-maik',
vbActive: 'btn btn-block btn-maik-active',
});
} else {
this.setState({
cfActive: 'btn btn-block btn-maik-active',
vbActive: 'btn btn-block btn-maik',
currentCFDest: "(" + result.cfu['destinations'][0].simple_destination + ")",
});
}
} else {
this.setState({
cfActive: 'btn btn-block btn-maik',
vbActive: 'btn btn-block btn-maik',
});
}
Meteor.call('getCurrentVM', this.props.custs[0].subscriber_id, (err, res) => {
if(!err) {
var vms = JSON.parse(res.content);
this.setState({
vmCount: vms.total_count,
isLoading: false
});
} else {
console.log(err)
}
});
} else {
console.log(err);
}
});
}
}
当用户新登录应用程序时,所有数据都在那里,您可以使用该应用程序。但是,当您(意外)刷新时,控制台会显示以下错误:
无法读取未定义的属性“subscriber_id”
我似乎无法找出原因。有什么建议么?