From eac617d6ee74fb20cd69fdbc78a77ee07f5e6ba3 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Tue, 12 Apr 2016 01:26:11 -0700 Subject: [PATCH] Add null check before accessing the refresh control ref Summary:Unmounting the RefreshControl during onRefresh callback causes the native ref to become null, this simply adds a null check to prevent the crash. Closes https://github.com/facebook/react-native/pull/6931 Differential Revision: D3167637 fb-gh-sync-id: c2420b7a3b672d62dd349a6d35bb05399a00620c fbshipit-source-id: c2420b7a3b672d62dd349a6d35bb05399a00620c --- Libraries/Components/RefreshControl/RefreshControl.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/Components/RefreshControl/RefreshControl.js b/Libraries/Components/RefreshControl/RefreshControl.js index 64e9a76ea..f79305d93 100644 --- a/Libraries/Components/RefreshControl/RefreshControl.js +++ b/Libraries/Components/RefreshControl/RefreshControl.js @@ -133,7 +133,10 @@ const RefreshControl = React.createClass({ _onRefresh() { this.props.onRefresh && this.props.onRefresh(); - this._nativeRef.setNativeProps({refreshing: this.props.refreshing}); + + if (this._nativeRef) { + this._nativeRef.setNativeProps({refreshing: this.props.refreshing}); + } }, });