From 2249af4cde5571f95fec5b95ef22f169a27daf31 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 26 Jul 2022 11:37:59 -0400 Subject: [PATCH] [Gekidou] RN patch (#6513) --- app/components/post_list/config.ts | 2 +- patches/react-native+0.68.2.patch | 94 ------------------------------ 2 files changed, 1 insertion(+), 95 deletions(-) diff --git a/app/components/post_list/config.ts b/app/components/post_list/config.ts index 88ec46633..877145287 100644 --- a/app/components/post_list/config.ts +++ b/app/components/post_list/config.ts @@ -22,7 +22,7 @@ export const SCROLL_POSITION_CONFIG = { }; export const VIEWABILITY_CONFIG = { itemVisiblePercentThreshold: 50, - minimumViewTime: 100, + minimumViewTime: 500, }; export const MORE_MESSAGES = { diff --git a/patches/react-native+0.68.2.patch b/patches/react-native+0.68.2.patch index adabc658d..62d5c982c 100644 --- a/patches/react-native+0.68.2.patch +++ b/patches/react-native+0.68.2.patch @@ -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 = {| - /** -@@ -141,6 +142,10 @@ type OptionalProps = {| - * 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 extends React.PureComponent, void> { - }; - } - -- _renderer = () => { -- const {ListItemComponent, renderItem, columnWrapperStyle} = this.props; -- const numColumns = numColumnsOrDefault(this.props.numColumns); -+ _renderer = ( -+ ListItemComponent: ?(React.ComponentType | React.Element), -+ renderItem: ?RenderItemType, -+ columnWrapperStyle: ?ViewStyleProp, -+ numColumns: ?number, -+ extraData: ?any, -+ ) => { -+ const cols = numColumnsOrDefault(numColumns); - - let virtualizedListRenderKey = ListItemComponent - ? 'ListItemComponent' -@@ -605,7 +615,7 @@ class FlatList extends React.PureComponent, 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) => { -- if (numColumns > 1) { -+ if (cols > 1) { - const {item, index} = info; - invariant( - Array.isArray(item), -@@ -616,7 +626,7 @@ class FlatList extends React.PureComponent, 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 extends React.PureComponent, 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 ( - extends React.PureComponent, 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