Strange behavior/loading patterns when using React + Meteor pre-filling forms


#1

Cliffs:

I’m trying to pre-fill forms from a user’s previous entries, which is all stored in a MongoDB colelction I do this doing conventional Javascript:

componentDidMount(){
 let name = document.getElementById("name");
    name.value = this.props.iData.name;
}

This works fine unless I refresh the page, in which case I get an error that this.props.iData is undefined. So, whenever I visit the page with the pre-filled data, it works fine and subscription works fine. But when I refresh that same page, the subscription doesn’t load fast enough.

The subscription is done like this:

export default createContainer(function(){
  const subHandle = Meteor.subscribe("iData", function(){
  });
  const isLoading = !subHandle.ready();
  return {
    isLoading,
    iData: Poll.find().fetch(),
  }
}, UserSettings)

I must be doing something wrong for this to happen the way it’s happening.