I'm using reactjs with redux and this is a part of one of my components.
I want to render postList
of the promise which is returned by handleFetchPosts
, but the render()
function starts rendering before the then()
of shouldComponentUpdate
is completed.
How can I postpone rendering or rerender after the then
is completed?
constructor(props) { super(props); this.postList = props.postList; this.props.handleFetchPosts('/main', 'about', '');}shouldComponentUpdate(nextProps) { if (this.postList !== nextProps.postList) { nextProps.postList.then(data => { this.postList = data; }); return true; } else { return false; }}render() { return (<div className="content"><p> {this.postList +""} {/*content*/}</p></div> );}