Calling setState in render is not avoidable
React document states that the render
function should be pure which mean it should not use this.setState
in it .However, I believe when the state is depended on ‘remote’ i.e. result from ajax call.The only solution is setState()
inside a render
function