RefreshControl on initial render will not beginRefresh when refreshing state is false

Summary:
There's an edge case in the `RefreshControl` which causes it to show as refreshing when the state is set to false. When the component is initialized with `refreshing` set to `true` on initial render but set to `false` before `layoutSubviews` is called, it will call `beginRefresh` and ignore its state. That's because `layoutSubviews` never checks if `_currentRefreshingState` is in fact still `true`, it merely assumes it is.

This is fixed by simply doing a check for `_currentRefreshingState` before entering `beginRefresh` from `layoutSubviews`.
Closes https://github.com/facebook/react-native/pull/7556

Differential Revision: D3300124

fbshipit-source-id: d1dce8612e2c03b1f14284d513803d00af4b5c8a
This commit is contained in:
Arno Fortelny 2016-05-13 14:40:47 -07:00 коммит произвёл Facebook Github Bot 3
Родитель 8975bb8e70
Коммит cac5ce3b93
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -35,7 +35,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
// If the control is refreshing when mounted we need to call // If the control is refreshing when mounted we need to call
// beginRefreshing in layoutSubview or it doesn't work. // beginRefreshing in layoutSubview or it doesn't work.
if (_isInitialRender && _initialRefreshingState) { if (_currentRefreshingState && _isInitialRender && _initialRefreshingState) {
[self beginRefreshing]; [self beginRefreshing];
} }
_isInitialRender = false; _isInitialRender = false;