I googled and found some relevant answers but they don't seem to be complete. eg. react.js don't render until ajax request finish
One of the answer suggest to put if else in template, and I have the following Loader component doing this:
var LoaderWrapper = function (props) {
return (
<div>
{props.loaded ? props.children :
<div className="margin-fixer">
<div className="sk-spinner sk-spinner-wave">
<div className="sk-rect1"></div>
<div className="sk-rect2"></div>
<div className="sk-rect3"></div>
<div className="sk-rect4"></div>
<div className="sk-rect5"></div>
</div>
</div>}
</div>
)
};
Now if I use this wrapper:
<LoaderWrapper loaded={variable!=null}>
<MyComponent variable={variable}/>
</LoaderWrapper>
In MyComponent:
render () {
const {variable} = this.props;
return (<div>{variable.abc}</div>)
}
Problem is that still complains about variable is null.
Also tried the following, complains about the same thing...
<LoaderWrapper loaded={false}>
<MyComponent variable={variable}/>
</LoaderWrapper>