You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using inverted section list for a chat app. I need to implement scroll to the new received messages. I can calculate the index of section and index of specific item, but scrollToLocation method throw 'undefined is not a function'. If apply same code for built in SectionList, scroll works without errors.
I'm using inverted section list for a chat app. I need to implement scroll to the new received messages. I can calculate the index of section and index of specific item, but scrollToLocation method throw 'undefined is not a function'. If apply same code for built in SectionList, scroll works without errors.
RN version: 0.70.5
useEffect(() => {
if (messages.length && !newMessageScrolled) {
const sectionIndex = batchedMessages.findIndex((section) =>
section?.data?.find((a) => a.messageIndex === newMessagesCount.index)
);
if (sectionIndex !== -1 && newMessagesCount.index > 0 && listRef.current) {
listRef.current.scrollToLocation({ sectionIndex: sectionIndex, itemIndex: newMessagesCount.index });
setNewMessageScrolled(true);
}
}
}, [newMessageScrolled, newMessagesCount]);
<InvertedSectionList
ref={listRef}
contentContainerStyle={getListContainerStyle()}
onScrollToIndexFailed={handleScrollError}
bounces={false}
keyExtractor={listKeyExtractor}
sections={batchedMessages}
scrollEventThrottle={16}
onScroll={handleListScroll}
initialNumToRender={isTablet ? 10 : 16}
renderItem={renderMessage}
renderSectionFooter={renderSectionHeader}
stickyHeaderHiddenOnScroll={true}
stickySectionHeadersEnabled={true}
ListEmptyComponent={renderEmpty}
ListFooterComponent={renderFooter}
/>
The text was updated successfully, but these errors were encountered: