From cac5ce3b930dfb1bd0dcc9de65ac20e9a0eee015 Mon Sep 17 00:00:00 2001 From: Arno Fortelny Date: Fri, 13 May 2016 14:40:47 -0700 Subject: [PATCH] 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 --- React/Views/RCTRefreshControl.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/React/Views/RCTRefreshControl.m b/React/Views/RCTRefreshControl.m index a28078c1082..1b11bdcfe08 100644 --- a/React/Views/RCTRefreshControl.m +++ b/React/Views/RCTRefreshControl.m @@ -35,7 +35,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder) // If the control is refreshing when mounted we need to call // beginRefreshing in layoutSubview or it doesn't work. - if (_isInitialRender && _initialRefreshingState) { + if (_currentRefreshingState && _isInitialRender && _initialRefreshingState) { [self beginRefreshing]; } _isInitialRender = false;