Question: do not use setstate in componentdidmount?
Answer: It is not an anti-pattern to call setState in componentDidMount . In fact, ReactJS provides an example of this in their documentation: You should populate data with AJAX calls in the componentDidMount lifecycle method. This is so you can use setState to update your component when the data is retrieved.