[fix] ScrollView dependency on 'style' forwarding for sticky headers

Not every item that may be rendered by a ScrollView will forward 'style', so cloning the item element is not safe. Instead, we can wrap the item in a 'View' and apply the styles for the sticky header to this element.

Close #1175
This commit is contained in:
Julian Hundeloh
2018-11-14 14:54:48 +01:00
committed by Nicolas Gallagher
parent 6d92cc5ec3
commit 145f80409d

View File

@@ -168,7 +168,7 @@ const ScrollView = createReactClass({
!horizontal && Array.isArray(stickyHeaderIndices)
? React.Children.map(this.props.children, (child, i) => {
if (child && stickyHeaderIndices.indexOf(i) > -1) {
return React.cloneElement(child, { style: [child.props.style, styles.stickyHeader] });
return <View style={styles.stickyHeader}>{child}</View>;
} else {
return child;
}