Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(CLNP-906): inverted flatlist android warning #124

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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