我正在将 React 与 Meteor 一起使用,并且无法更新我的数据。这是我在组件getMeteorData()
中的代码Conversation
getMeteorData() {
var vertices_handle = Meteor.subscribe('VertexIDs', this.props.conversation_id);
return {
vertices: Vertices.find({conversation: this.props.conversation_id}).fetch(),
ready: vertices_handle.ready()
};
}
订阅只返回帖子(顶点)的 ID,我使用这些数据来渲染更多组件:
renderPostList() {
return this.data.vertices.map((post) => {
return <PostThread
key = {post._id}
root_id = {post._id}
conversation_id = {this.props.conversation_id} />;
});
}
在PostThread
组件中,我通过 ID 单独订阅每个帖子,以根据需要获取其余数据。但是,当我从 Vertices 集合中删除某些内容时,该Conversation
组件似乎没有更新。我可以在 MeteorToys 中看到客户端上的 Vertices 集合已删除了一个帖子,但这种更改有时不会反映在 UI 中。有时,当帖子被删除时,UI 会正确更新,但有时却没有,我无法找到这种模式。