React Component Mount, Wait for Subscriptions Ready?


Hey everyone!

Is there a recommended pattern to have a React component’s mounting operation wait for the component’s subscription’s to be ready before actually mounting?



You can’t really control when the component mounts, but you can control what’s displayed based on if the subscription is ready or not.

MyComponent = React.createClass({
  mixins: [ReactMeteorData],
  getMeteorData() {
    const handle = Meteor.subscribe('things');
    return {
      ready: handle.ready(),
      things: Things.find()
  render() {
    if (! {
      return <div>Loading...</div>
    return <div>
      I've got data!


Hi, I’m using universe:utilities-react instead of ReactMeteorData. And it works pretty well. You could take a look at the their Subscription mixin.


Had no idea that existed… does that reactively update state in React? seems awesome.


The behavior is the same as getMeteorData, so answer is yes.