I wanted to illustrate that you should not perform long running operations inside a setState method.
Your example is OK in terms of the setState method being small and short. But a loop iterating over 10,000 times with just a print output is probably never a good idea in any productive system :)