I am new to ReactJS and trying to understand it. Now I have a situation where I am loading information needed for rendering. But as it is asynchronous the component renders
You need to do something like below:
var InfoPage = React.createClass({
getInitialState: function() {
return {info: "loading ... "};
},
componentDidMount: function() {
this.getInfo();
},
render: function() {
return (
info: {this.state.info}
);
},
getInfo:function(){
$.ajax({ url:"restapi/getInfo/whatever", .... }).success(function(res){
this.setState({info:res});
}.bind(this));
}
});