[Gekidou] RN patch (#6513)

This commit is contained in:
Elias Nahum 2022-07-26 11:37:59 -04:00 committed by GitHub
parent 81c274b334
commit 2249af4cde
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 95 deletions

View file

@ -22,7 +22,7 @@ export const SCROLL_POSITION_CONFIG = {
};
export const VIEWABILITY_CONFIG = {
itemVisiblePercentThreshold: 50,
minimumViewTime: 100,
minimumViewTime: 500,
};
export const MORE_MESSAGES = {

View file

@ -34,100 +34,6 @@ index a6826f3..a7b904b 100644
child.props.onLayout(event);
}
};
diff --git a/node_modules/react-native/Libraries/Lists/FlatList.js b/node_modules/react-native/Libraries/Lists/FlatList.js
index f78ca22..8e81037 100644
--- a/node_modules/react-native/Libraries/Lists/FlatList.js
+++ b/node_modules/react-native/Libraries/Lists/FlatList.js
@@ -26,6 +26,7 @@ import type {
} from './ViewabilityHelper';
import type {RenderItemType, RenderItemProps} from './VirtualizedList';
import {keyExtractor as defaultKeyExtractor} from './VirtualizeUtils';
+import memoizeOne from 'memoize-one';
type RequiredProps<ItemT> = {|
/**
@@ -141,6 +142,10 @@ type OptionalProps<ItemT> = {|
* See `ScrollView` for flow type and further documentation.
*/
fadingEdgeLength?: ?number,
+ /**
+ * Enable an optimization to memoize the item renderer to prevent unnecessary rerenders.
+ */
+ strictMode?: boolean,
|};
/**
@@ -578,9 +583,14 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
};
}
- _renderer = () => {
- const {ListItemComponent, renderItem, columnWrapperStyle} = this.props;
- const numColumns = numColumnsOrDefault(this.props.numColumns);
+ _renderer = (
+ ListItemComponent: ?(React.ComponentType<any> | React.Element<any>),
+ renderItem: ?RenderItemType<ItemT>,
+ columnWrapperStyle: ?ViewStyleProp,
+ numColumns: ?number,
+ extraData: ?any,
+ ) => {
+ const cols = numColumnsOrDefault(numColumns);
let virtualizedListRenderKey = ListItemComponent
? 'ListItemComponent'
@@ -605,7 +615,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
* This comment suppresses an error found when Flow v0.111 was deployed.
* To see the error, delete this comment and run Flow. */
[virtualizedListRenderKey]: (info: RenderItemProps<ItemT>) => {
- if (numColumns > 1) {
+ if (cols > 1) {
const {item, index} = info;
invariant(
Array.isArray(item),
@@ -616,7 +626,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
{item.map((it, kk) => {
const element = renderer({
item: it,
- index: index * numColumns + kk,
+ index: index * cols + kk,
separators: info.separators,
});
return element != null ? (
@@ -632,14 +642,19 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
};
};
+ _memoizedRenderer = memoizeOne(this._renderer);
+
render(): React.Node {
const {
numColumns,
columnWrapperStyle,
removeClippedSubviews: _removeClippedSubviews,
+ strictMode = false,
...restProps
} = this.props;
+ const renderer = strictMode ? this._memoizedRenderer : this._renderer;
+
return (
<VirtualizedList
{...restProps}
@@ -651,7 +666,13 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
removeClippedSubviews={removeClippedSubviewsOrDefault(
_removeClippedSubviews,
)}
- {...this._renderer()}
+ {...renderer(
+ this.props.ListItemComponent,
+ this.props.renderItem,
+ columnWrapperStyle,
+ numColumns,
+ this.props.extraData,
+ )}
/>
);
}
diff --git a/node_modules/react-native/Libraries/Lists/VirtualizedList.js b/node_modules/react-native/Libraries/Lists/VirtualizedList.js
index 6de43b7..2c18c92 100644
--- a/node_modules/react-native/Libraries/Lists/VirtualizedList.js