When "loadInitialCount()" is called the first time, "Loading..." won't show up. But it's shown when click "reload" button.
I found that this is because "GlobalStateProvider" registers listener inside "useEffect" which is called after "useEffect" of "ItemList" component . So the "loading" state is not updated the first time.
Problem: global state does not update when dispatch from inside useEffect the first time.
Example:
When "loadInitialCount()" is called the first time, "Loading..." won't show up. But it's shown when click "reload" button.
I found that this is because "GlobalStateProvider" registers listener inside "useEffect" which is called after "useEffect" of "ItemList" component . So the "loading" state is not updated the first time.