Skip to content

Commit a8395fe

Browse files
authored
fix stickySectionHeader re-render issue
Close facebook#13500
1 parent 7dd2cd3 commit a8395fe

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

Libraries/Components/ScrollView/ScrollViewStickyHeader.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ class ScrollViewStickyHeader extends React.Component {
6161

6262
render() {
6363
const {measured, layoutHeight, layoutY, nextHeaderLayoutY} = this.state;
64+
const inputRange: Array<number> = [-1, 0];
65+
const outputRange: Array<number> = [0, 0];
6466

65-
let translateY;
6667
if (measured) {
6768
// The interpolation looks like:
6869
// - Negative scroll: no translation
@@ -74,8 +75,8 @@ class ScrollViewStickyHeader extends React.Component {
7475
// header to continue scrolling up and make room for the next sticky header.
7576
// In the case that there is no next header just translate equally to
7677
// scroll indefinetly.
77-
const inputRange = [-1, 0, layoutY];
78-
const outputRange: Array<number> = [0, 0, 0];
78+
inputRange.push(layoutY);
79+
outputRange.push(0);
7980
// Sometimes headers jump around so we make sure we don't violate the monotonic inputRange
8081
// condition.
8182
const collisionPoint = (nextHeaderLayoutY || 0) - layoutHeight;
@@ -86,14 +87,12 @@ class ScrollViewStickyHeader extends React.Component {
8687
inputRange.push(layoutY + 1);
8788
outputRange.push(1);
8889
}
89-
translateY = this.props.scrollAnimatedValue.interpolate({
90-
inputRange,
91-
outputRange,
92-
});
93-
} else {
94-
translateY = 0;
9590
}
9691

92+
const translateY = this.props.scrollAnimatedValue.interpolate({
93+
inputRange,
94+
outputRange,
95+
});
9796
const child = React.Children.only(this.props.children);
9897

9998
return (

0 commit comments

Comments
 (0)