mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-02 02:25:22 +00:00
[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:
committed by
Nicolas Gallagher
parent
6d92cc5ec3
commit
145f80409d
@@ -168,7 +168,7 @@ const ScrollView = createReactClass({
|
|||||||
!horizontal && Array.isArray(stickyHeaderIndices)
|
!horizontal && Array.isArray(stickyHeaderIndices)
|
||||||
? React.Children.map(this.props.children, (child, i) => {
|
? React.Children.map(this.props.children, (child, i) => {
|
||||||
if (child && stickyHeaderIndices.indexOf(i) > -1) {
|
if (child && stickyHeaderIndices.indexOf(i) > -1) {
|
||||||
return React.cloneElement(child, { style: [child.props.style, styles.stickyHeader] });
|
return <View style={styles.stickyHeader}>{child}</View>;
|
||||||
} else {
|
} else {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user