流星+ React中的条件渲染

流星+ React中的条件渲染,第1张

流星+ React中的条件渲染

您必须等待数据完成同步。之所以会出现闪存,是因为最初的MiniMongo集合为空。(此外,您可能要避免

Collection.find()
在渲染函数中使用。)

假设您使用Meteor 1.3.x:

export const MyComponent = createContainer(() => {  let subscription = Meteor.subscribe('something');  if (!subscription.ready()) return {};  return {    tokens: Tokens.find().fetch()  }}, InternalComponent);

然后检查

props.tokens
您的React组件中是否存在。

class InternalComponent extends React.Component {  render() {    if (!this.props.tokens || this.props.tokens.length > 0) return;    return <TokenForm />;  }}

在此处了解有关订阅的更多信息:http :
//docs.meteor.com/#/full/meteor_subscribe



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5615007.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存