From d841db23373ca2771891ba34a1d7ea2c71ee8ac7 Mon Sep 17 00:00:00 2001 From: Bruno Lemos Date: Sun, 30 Sep 2018 03:26:56 -0300 Subject: [PATCH] [fix] VirtualizedList sticky header support The way that sticky headers work on web requires the ScrollView to apply 'position:sticky' to a clone of the element. This wasn't working for VirtualizedList because the style prop was not passed to the default CellRendererComponent implementation. Fix #1066 Close #1122 --- .../react-native/VirtualizedList/index.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/react-native-web/src/vendor/react-native/VirtualizedList/index.js b/packages/react-native-web/src/vendor/react-native/VirtualizedList/index.js index c38bb3d2..a95d3e0c 100644 --- a/packages/react-native-web/src/vendor/react-native/VirtualizedList/index.js +++ b/packages/react-native-web/src/vendor/react-native/VirtualizedList/index.js @@ -1562,6 +1562,7 @@ class CellRenderer extends React.Component< renderItem: renderItemType, }, prevCellKey: ?string, + style: ?DangerouslyImpreciseStyleProp, }, $FlowFixMeState, > { @@ -1630,6 +1631,7 @@ class CellRenderer extends React.Component< index, inversionStyle, parentProps, + style, } = this.props; const {renderItem, getItemLayout} = parentProps; invariant(renderItem, 'no renderItem!'); @@ -1649,9 +1651,9 @@ class CellRenderer extends React.Component< ); const cellStyle = inversionStyle ? horizontal - ? [{flexDirection: 'row-reverse'}, inversionStyle] - : [{flexDirection: 'column-reverse'}, inversionStyle] - : horizontal ? [{flexDirection: 'row'}, inversionStyle] : inversionStyle; + ? [styles.rowReverse, inversionStyle, style] + : [styles.columnReverse, inversionStyle, style] + : horizontal ? [styles.row, inversionStyle, style] : [inversionStyle, style]; if (!CellRendererComponent) { return ( @@ -1702,6 +1704,15 @@ const styles = StyleSheet.create({ horizontallyInverted: { transform: [{scaleX: -1}], }, + row: { + flexDirection: 'row' + }, + rowReverse: { + flexDirection: 'row-reverse' + }, + columnReverse: { + flexDirection: 'column-reverse' + } }); export default VirtualizedList;