Fixed possible issues that may occur when code altered child views in any of the view state callback functions: `didCreateLayer`, `didAppendToDocument`, `didHideInDocument`, `didShowInDocument`. The issue was that the callback functions were called on the parent before the child was updated to the proper new state. For example, if a developer set the visibility of a child view to false in `didCreateLayer`, at that point the child view would have still been in an unrendered state and optimizations preventing visibility changes to unrendered views would have meant the visibility change would have been lost.

Refactored the view statechart code significantly to improve the clarity of the state transition handling and fixes #1269.