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
This commit is contained in:
Janic Duplessis 2016-04-12 01:26:11 -07:00 committed by Facebook Github Bot 6
parent 24f03af0c3
commit eac617d6ee
1 changed files with 4 additions and 1 deletions

View File

@ -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});
}
},
});