From 152a466ee4167476b8a8e89567e2dea128c7b26d Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Wed, 17 May 2017 01:46:43 -0400 Subject: [PATCH] Fix sticky headers when rerendering --- Libraries/Components/ScrollView/ScrollView.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 723bcfa4f181..4c5e66ae94bd 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -490,18 +490,15 @@ const ScrollView = React.createClass({ }, _updateAnimatedNodeAttachment: function() { + if (this._scrollAnimatedValueAttachment) { + this._scrollAnimatedValueAttachment.detach(); + } if (this.props.stickyHeaderIndices && this.props.stickyHeaderIndices.length > 0) { - if (!this._scrollAnimatedValueAttachment) { - this._scrollAnimatedValueAttachment = Animated.attachNativeEvent( - this._scrollViewRef, - 'onScroll', - [{nativeEvent: {contentOffset: {y: this._scrollAnimatedValue}}}] - ); - } - } else { - if (this._scrollAnimatedValueAttachment) { - this._scrollAnimatedValueAttachment.detach(); - } + this._scrollAnimatedValueAttachment = Animated.attachNativeEvent( + this._scrollViewRef, + 'onScroll', + [{nativeEvent: {contentOffset: {y: this._scrollAnimatedValue}}}] + ); } },