launchplatform / inverted-section-list Goto Github PK
View Code? Open in Web Editor NEWA React Native component that implements SectionList with inverted direction and working sticky header
License: MIT License
A React Native component that implements SectionList with inverted direction and working sticky header
License: MIT License
When to scroll about 100+ items, empty areas appear in the list. Also empty areas sometimes appear when I'm open a keyboard. If use a react native section list, there is no empty areas. But I need an inverted section list with sticky headers, what is not available out of the box in react native for current version.
Version of react native: 0.70.4
example of rendering 150 items
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}
/>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.