The explicit use of setState will be for user interface components that have a local display state but are not related to the global application. For example, a boolean representing whether a particular drop-down menu is actively displayed does not have to be in a global state, so it is more convenient to control the state of a menu component.
Other examples may include the collapse / expand lines in the hierarchy accordion display. Or perhaps the currently selected tab in the tab navigation. However, in both of these examples, you can still process the state of the user interface globally. For example, this would be necessary if you would like to keep the expand / collapse state in the browser repository so that it would remain when the page was refreshed.
In practice, it is usually simpler to implement such user interface elements with a local state and reorganize them into a global state as necessary.
mjhm Jan 10 '16 at 23:03 2016-01-10 23:03
source share