1

在我的流星應用程序,我有一個集合的定義是這樣的(評估 '_reactNativeMeteor2.default.collection( 「信息」)找到()取()。'):不確定是不是一個函數

this.collections.Messages = new Mongo.Collection("messages"); 

現在,我嘗試從一個react native meteor連接到它是這樣的:

import React, { Component } from 'react'; 
import Meteor, { createContainer } from 'react-native-meteor'; 
import MessageListComponent from '../routes/messageList'; 

export default MessageListContainer = createContainer(() => { 
    const messagesHandle = Meteor.subscribe('userMessage'); 
    const loading = !messagesHandle.ready(); 
    const messages = Meteor.collection("messages").find().fetch(); 
    return { 
     loading, 
     messages 
    }; 
}, MessageListComponent); 

但它下面紅色的錯誤消息返回的設備:

undefined is not a function (evaluating '_reactNativeMeteor2.default.collection("messages").find().fetch()') 

這是什麼問題?

回答

1

嘗試消除從您的郵件常量()的獲取:

const messages = Meteor.collection('messages').find(); 

的獲取光標轉換成一個數組,而且很可能是沒有必要在這裏。此外,這行是唯一一個你有雙引號,但我不確定這是相關的。