In my Meteor app I have a collection definition like this:

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

Now I try to connect to it from a react native meteor like this:

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);

But it's return below red error message on device:

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

What is the problem guys?

1

There are 1 answers

0
kwishnu On BEST ANSWER

Try eliminating the fetch() from your messages const:

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

The fetch converts the cursor into an array, and probably isn't necessary here. Also, this line is the only one where you have double quotes, but I'm not sure that that is relevant.