diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 66a3baaea66f53..ff9c3d3052fcf8 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -334,14 +334,18 @@ const ScrollView = React.createClass({ mixins: [ScrollResponder.Mixin], - _scrollAnimatedValue: new Animated.Value(0), - _scrollAnimatedValueAttachment: null, - _stickyHeaderRefs: new Map(), + _scrollAnimatedValue: (null: ?Animated.Value), + _scrollAnimatedValueAttachment: (null: ?{detach: () => void}), + _stickyHeaderRefs: (new Map(): Map), getInitialState: function() { return this.scrollResponderMixinGetInitialState(); }, + componentWillMount: function() { + this._scrollAnimatedValue = new Animated.Value(0); + }, + componentDidMount: function() { this._updateAnimatedNodeAttachment(); }, @@ -350,6 +354,12 @@ const ScrollView = React.createClass({ this._updateAnimatedNodeAttachment(); }, + componentWillUnmount: function() { + if (this._scrollAnimatedValueAttachment) { + this._scrollAnimatedValueAttachment.detach(); + } + }, + setNativeProps: function(props: Object) { this._scrollViewRef && this._scrollViewRef.setNativeProps(props); }, diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index 24596e2e99a2cf..799061769d2d1f 100644 --- a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -13,11 +13,8 @@ const Animated = require('Animated'); const React = require('React'); -const UIManager = require('UIManager'); const StyleSheet = require('StyleSheet'); -const findNodeHandle = require('findNodeHandle'); - type Props = { children?: React.Element<*>, scrollAnimatedValue: Animated.Value, @@ -50,8 +47,8 @@ class ScrollViewStickyHeader extends React.Component { let translateY; if (measured) { - const inputRange = [-1, layoutY]; - const outputRange: Array = [0, 0]; + const inputRange = [-1, 0, layoutY]; + const outputRange: Array = [-1, 0, 0]; if (nextHeaderLayoutY != null) { inputRange.push(nextHeaderLayoutY, nextHeaderLayoutY + 1); outputRange.push(nextHeaderLayoutY - layoutY, nextHeaderLayoutY - layoutY);