我在withTracker mongo find函数中遇到参考错误?

时间:2019-07-12 12:22:02

标签: reactjs meteor

我遇到错误 AllCustomers.js:54 Uncaught ReferenceError:初始化之前无法访问'userKisan',但是我已经导入了相关文件,但不知道为什么显示此错误,github代码是{ {3}}

import {userKisan}   from '../api/userKisan';

  export default withTracker( ( props ) => {
    const filesHandle = Meteor.subscribe('userKisan');
    const docsReadyYet = filesHandle.ready();
    const userKisan = userKisan.find({}).fetch(); // error

    return {
      docsReadyYet,
      userKisan,
    };
  })(AllCustomers);

1 个答案:

答案 0 :(得分:0)

import {userKisandb}   from '../api/userKisan';

export default withTracker( ( props ) => {
    const filesHandle = Meteor.subscribe('userKisan');
    const docsReadyYet = filesHandle.ready();
    const userKisan = userKisandb.find({}).fetch(); 

    return {
      docsReadyYet,
      userKisan,
    };
  })(AllCustomers);