Trying to subscribe to a collectionusing react-meteor-hooks but loading is always true

112 Views Asked by At

Trying to implement 'react-meteor-hooks, but 'loading' variable is always true:

import React from 'react';
import { useSubscription, useMongoFetch } from 'react-meteor-hooks';
import { Comments } from '../../../../collections/comments';

export const GiveComments = (props) => {

     const loading = useSubscription('getComments');

    if (loading) {
         console.log('loading... ');
    } else {
        const allComments = useMongoFetch(Comments.find({}));
        console.log('loaded: ', allComments);
      }
    return (null);
};

Publishing:

  Meteor.publish('getComments', function() {
    return Comments.find({});
  });

These hooks looks amazing, but can't get it to work. Why 'loading' does not stop?

0

There are 0 best solutions below