forked from devhubapp/devhub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-add patch to fix VirtualizedList memoization
- Loading branch information
1 parent
ec9bb0f
commit e86c7dd
Showing
2 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
diff --git a/node_modules/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/node_modules/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js | ||
index c9a967f..bb5c547 100644 | ||
--- a/node_modules/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js | ||
+++ b/node_modules/react-native/Libraries/Components/ScrollView/ScrollViewStickyHeader.js | ||
@@ -59,7 +59,7 @@ class ScrollViewStickyHeader extends React.Component<Props, State> { | ||
this.props.onLayout(event); | ||
const child = React.Children.only(this.props.children); | ||
if (child.props.onLayout) { | ||
- child.props.onLayout(event); | ||
+ child.props.onLayout(event, child.props.cellKey, child.props.index); | ||
} | ||
}; | ||
|
||
diff --git a/node_modules/react-native/Libraries/Lists/VirtualizedList.js b/node_modules/react-native/Libraries/Lists/VirtualizedList.js | ||
index 7dffc17..ebc0fc6 100644 | ||
--- a/node_modules/react-native/Libraries/Lists/VirtualizedList.js | ||
+++ b/node_modules/react-native/Libraries/Lists/VirtualizedList.js | ||
@@ -746,11 +746,16 @@ class VirtualizedList extends React.PureComponent<Props, State> { | ||
const { | ||
CellRendererComponent, | ||
ItemSeparatorComponent, | ||
+ ListItemComponent, | ||
data, | ||
+ debug, | ||
+ extraData, | ||
getItem, | ||
getItemCount, | ||
+ getItemLayout, | ||
horizontal, | ||
keyExtractor, | ||
+ renderItem, | ||
} = this.props; | ||
const stickyOffset = this.props.ListHeaderComponent ? 1 : 0; | ||
const end = getItemCount(data) - 1; | ||
@@ -776,9 +781,13 @@ class VirtualizedList extends React.PureComponent<Props, State> { | ||
key={key} | ||
prevCellKey={prevCellKey} | ||
onUpdateSeparators={this._onUpdateSeparators} | ||
- onLayout={e => this._onCellLayout(e, key, ii)} | ||
+ onLayout={this._onCellLayout} | ||
onUnmount={this._onCellUnmount} | ||
- parentProps={this.props} | ||
+ getItemLayout={getItemLayout} | ||
+ renderItem={renderItem} | ||
+ ListItemComponent={ListItemComponent} | ||
+ extraData={extraData} | ||
+ debug={debug} | ||
ref={ref => { | ||
this._cellRefs[key] = ref; | ||
}} | ||
@@ -1184,7 +1193,7 @@ class VirtualizedList extends React.PureComponent<Props, State> { | ||
} | ||
}; | ||
|
||
- _onCellLayout(e, cellKey, index) { | ||
+ _onCellLayout = (e, cellKey, index): void => { | ||
const layout = e.nativeEvent.layout; | ||
const next = { | ||
offset: this._selectOffset(layout), | ||
@@ -1225,7 +1234,7 @@ class VirtualizedList extends React.PureComponent<Props, State> { | ||
|
||
this._computeBlankness(); | ||
this._updateViewableItems(this.props.data); | ||
- } | ||
+ }; | ||
|
||
_onCellUnmount = (cellKey: string) => { | ||
const curr = this._frames[cellKey]; | ||
@@ -1760,14 +1769,13 @@ type CellRendererProps = { | ||
index: number, | ||
inversionStyle: ViewStyleProp, | ||
item: Item, | ||
- onLayout: (event: Object) => void, // This is extracted by ScrollViewStickyHeader | ||
+ onLayout: (event: Object, key: string, index: number) => void, // This is extracted by ScrollViewStickyHeader | ||
onUnmount: (cellKey: string) => void, | ||
onUpdateSeparators: (cellKeys: Array<?string>, props: Object) => void, | ||
- parentProps: { | ||
- getItemLayout?: ?Function, | ||
- renderItem?: ?RenderItemType<Item>, | ||
- ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>), | ||
- }, | ||
+ getItemLayout?: ?Function, | ||
+ renderItem: $PropertyType<OptionalProps, 'renderItem'>, | ||
+ ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>), | ||
+ debug: ?boolean, | ||
prevCellKey: ?string, | ||
}; | ||
|
||
@@ -1849,6 +1857,10 @@ class CellRenderer extends React.Component< | ||
this.props.onUnmount(this.props.cellKey); | ||
} | ||
|
||
+ _onLayout = (e): void => | ||
+ this.props.onLayout && | ||
+ this.props.onLayout(e, this.props.cellKey, this.props.index); | ||
+ | ||
_renderElement(renderItem, ListItemComponent, item, index) { | ||
if (renderItem && ListItemComponent) { | ||
console.warn( | ||
@@ -1883,14 +1895,16 @@ class CellRenderer extends React.Component< | ||
const { | ||
CellRendererComponent, | ||
ItemSeparatorComponent, | ||
+ ListItemComponent, | ||
+ debug, | ||
fillRateHelper, | ||
+ getItemLayout, | ||
horizontal, | ||
- item, | ||
index, | ||
inversionStyle, | ||
- parentProps, | ||
+ item, | ||
+ renderItem, | ||
} = this.props; | ||
- const {renderItem, getItemLayout, ListItemComponent} = parentProps; | ||
const element = this._renderElement( | ||
renderItem, | ||
ListItemComponent, | ||
@@ -1902,9 +1916,9 @@ class CellRenderer extends React.Component< | ||
/* $FlowFixMe(>=0.68.0 site=react_native_fb) This comment suppresses an | ||
* error found when Flow v0.68 was deployed. To see the error delete this | ||
* comment and run Flow. */ | ||
- getItemLayout && !parentProps.debug && !fillRateHelper.enabled() | ||
+ getItemLayout && !debug && !fillRateHelper.enabled() | ||
? undefined | ||
- : this.props.onLayout; | ||
+ : this._onLayout; | ||
// NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and | ||
// called explicitly by `ScrollViewStickyHeader`. | ||
const itemSeparator = ItemSeparatorComponent && ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters