Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-infinite-scroller

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-infinite-scroller

Infinite scroll component for React in ES6

  • 1.2.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
376K
decreased by-5.87%
Maintainers
1
Weekly downloads
 
Created

What is react-infinite-scroller?

The react-infinite-scroller package provides a simple way to implement infinite scrolling in React applications. It allows you to load more content as the user scrolls down the page, which is useful for displaying large lists of data without overwhelming the user or the browser.

What are react-infinite-scroller's main functionalities?

Basic Infinite Scrolling

This code demonstrates a basic implementation of infinite scrolling using the react-infinite-scroller package. It initializes a list of items and appends more items to the list as the user scrolls down. The `loadMore` function is called to fetch more items, and the `hasMore` state determines if more items should be loaded.


import React, { Component } from 'react';
import InfiniteScroll from 'react-infinite-scroller';

class InfiniteScrollExample extends Component {
  state = {
    items: Array.from({ length: 20 }),
    hasMore: true
  };

  loadMore = () => {
    if (this.state.items.length >= 100) {
      this.setState({ hasMore: false });
      return;
    }
    setTimeout(() => {
      this.setState({
        items: this.state.items.concat(Array.from({ length: 20 }))
      });
    }, 1500);
  };

  render() {
    return (
      <InfiniteScroll
        pageStart={0}
        loadMore={this.loadMore}
        hasMore={this.state.hasMore}
        loader={<div className="loader" key={0}>Loading ...</div>}
      >
        {this.state.items.map((_, index) => (
          <div key={index} style={{ height: 50, border: '1px solid black' }}>
            Item {index + 1}
          </div>
        ))}
      </InfiniteScroll>
    );
  }
}

export default InfiniteScrollExample;

Other packages similar to react-infinite-scroller

Keywords

FAQs

Package last updated on 13 Apr 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc