Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
infinite-section
Advanced tools
Virtualized window-based infinite-scrolling for sites and apps that load content in 'sections', that don't have a pre-determined width or height. Outperforms react-virtualized, and incredibly light-weight. Based on Facebook's infinite scrolling mechanism.
npm i infinite-section
Virtualized scroll libraries are often built to handle tabular data - and can do an almost infinite number of table rows and columns fast - but fall apart when your data is less 'structured', or requires full-window scrolling. This library handles those use cases - where you're building social feeds, or product lists, or a news site, or anywhere you've got data that loads in without you being able to know its visual width and height in advance. It's based on an interpretation of how sites like Facebook, Twitter, and Forbes deal with infinite scrolling on section-based data. This method is great for accessibility and is super-easy to implement.
Function Name | Description | Expects | Returns |
---|---|---|---|
useInfiniteSections (Hook) | Provide this hook with the amount of nodes currently available (i.e. nodes.length if working on an array) and a callback function to load more nodes. It'll work out the current view behind the scenes and choose what to render accordingly. | nodesAvailable: The amount of nodes currently available. loadMoreCallback (optional): give the hook a function to call when more nodes need to be fetched (i.e. from your server). | { currentView, setCurrentView, windowSize }: provide this object to the InfiniteSection component as props. |
InfiniteSection (Component) | The component that'll wrap all your section-based data. You'll probably use this like {nodes.map((node, viewIndex) => <InfiniteSection currentView={currentView} setCurrentView={setCurrentView} viewIndex={viewIndex} windowSize={windowSize}>{node.data}</InfiniteSection>)} . | children: Your React children to render. currentView, setCurrentView, windowSize: variables from useInfiniteSections hook. viewIndex: the index of the view within the array of your nodes. Probably the same as whatever you're passing for key. | React element containing your Node's children. |
FAQs
Virtualized window-based infinite-scrolling for sites and apps that load content in 'sections', that don't have a pre-determined width or height. Outperforms react-virtualized, and incredibly light-weight. Based on Facebook's infinite scrolling mechanism.
We found that infinite-section demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.