Using: Vanilla React and Flux Firebase
I'm trying to keep my store synced with realtime updates and so I've been following the instructions of this article Handling Synchronized Arrays with Real-Time Firebase Data
I've placed a call to a the WebAPI utilities class to fetch the initial data and placed it in the componentWillMount listener of my top level component as instructed by many.The code looks like so.
var MessageSection = require('./MessageSection.react');
var React = require('react');
var ThreadSection = require('./ThreadSection.react');
var ChatWebAPIUtils = require('../utils/ChatWebAPIUtils');
var ChatApp = React.createClass({
componentWillMount: function(){
ChatWebAPIUtils.getAllMessages(); **Here is my call to an action**
}
render: function() {
return (
<div className="chatapp">
<ThreadSection />
<MessageSection />
</div>
);
}
});
module.exports = ChatApp;
The problem is that even though my store will be loaded correctly, it looks like because it's an asynchronous fetch there will be calls to render components whose data is still not ready.
What is the conventional way to wait for the store be initialized before my program tries to render itself?