Skip to content

Commit

Permalink
Merge pull request #124 from sendbird/chore/flatlist-android-warning
Browse files Browse the repository at this point in the history
chore(CLNP-906): inverted flatlist android warning
  • Loading branch information
bang9 authored Sep 6, 2023
2 parents 834611d + 9c65d7d commit 7d4688b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/uikit-react-native/src/components/ChatFlatList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ import { NOOP, SendbirdMessage, getMessageUniqId, useFreshCallback } from '@send

import FlatListInternal from './FlatListInternal';

let ANDROID_BUG_ALERT_SHOWED = Platform.OS !== 'android';
function isInvertedFlatListFixedVersion() {
if (Platform.constants.reactNativeVersion?.major < 1) {
if (Platform.constants.reactNativeVersion?.minor < 73) {
if (Platform.constants.reactNativeVersion?.patch < 4) {
return false;
}
}
}
return true;
}

let ANDROID_BUG_ALERT_SHOWED = Platform.OS !== 'android' || isInvertedFlatListFixedVersion();
const BOTTOM_DETECT_THRESHOLD = 50;
const UNREACHABLE_THRESHOLD = Number.MIN_SAFE_INTEGER;

Expand All @@ -15,7 +26,6 @@ type Props = Omit<FlatListProps<SendbirdMessage>, 'onEndReached'> & {
onTopReached: () => void;
onScrolledAwayFromBottom: (value: boolean) => void;
};
// FIXME: Inverted FlatList performance issue on Android {@link https://github.com/facebook/react-native/issues/30034}
const ChatFlatList = forwardRef<RNFlatList, Props>(function ChatFlatList(
{ onTopReached, onBottomReached, onScrolledAwayFromBottom, onScroll, ...props },
ref,
Expand Down Expand Up @@ -44,7 +54,8 @@ const ChatFlatList = forwardRef<RNFlatList, Props>(function ChatFlatList(
ANDROID_BUG_ALERT_SHOWED = true;
// eslint-disable-next-line no-console
console.warn(
'UIKit Warning: The inverted FlatList has a performance issue on Android. Maybe this is a bug.\n' +
'UIKit Warning: The Inverted FlatList had performance issues on Android.\n' +
'This issue was fixed in 0.72.4+\n' +
'Please refer to the link: https://github.com/facebook/react-native/issues/30034',
);
}
Expand Down

0 comments on commit 7d4688b

Please sign in to comment.