meteor - 尝试使用 react-meteor-hooks 订阅集合,但加载总是正确的
问题描述
试图实现'react-meteor-hooks,但'loading'变量总是正确的:
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);
};
出版:
Meteor.publish('getComments', function() {
return Comments.find({});
});
这些钩子看起来很神奇,但不能让它工作。为什么“加载”不会停止?
解决方案
推荐阅读
- flurl - 在 Web 服务中使用 Flurl 处理对外部服务的调用
- file - 获取 IIS 日志记录中的内存使用情况
- apache-zookeeper - 是否可以避免嵌套的 RetryLoop.callWithRetry 调用,以便我获得一致的超时?
- r - 如何根据ggplot中的变量控制一行内的行大小?
- java - mybatis 没有返回延迟提取的所有行
- c# - 无法绑定多部分标识符“blah@blah.co.uk”。当使用 SqlCommand c#
- flutter - 如何维护 CupertinoSegmentedControl 的状态以实现国际化?
- macos - 在 MACOS 上使用 Catalyst 的 UIDocumentPickerViewController
- apache-kafka - 我可以在单个 mule 应用程序中有两个 kafka 消费者吗?都订阅了不同的主题
- python - matplotlib - 按数组的值着色