npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

observer-infinite-scroll

v1.1.6

Published

A React component that supports infinite scroll using Intersection Observer API

Downloads

108

Readme

Observer Infinite Scroll

This is a React component that enables infinite scrolling functionality in your web application. It allows you to load and display a large amount of data in a more efficient and user-friendly way.

Installation

To use this component in your React project, you can install it via npm:

npm install observer-infinite-scroll

Usage

To use the infinite scroll component in your application, you can import it and include it in your JSX code like this:

import React, { useState } from "react";
import InfiniteScroll from "observer-infinite-scroll";

const App = () => {
  const [data, setData] = useState([]);
  const [hasMore, setHasMore] = useState(true);

  const fetchMore = () => {
    // Load more items here
  };

  return (
    <InfiniteScroll
      fetchMore={fetchMore}
      hasMore={hasMore}
      loader={<p>Loading...</p>}
      endMessage={<p>No more items to load.</p>}
    >
      {data.map((item) => (
        <div key={item.id}>{item.name}</div>
      ))}
    </InfiniteScroll>
  );
};

In this example, fetchMore is a function to load more items, and hasMore is a boolean flag indicating whether there are more items to load. The loader prop is optional and can be used to display a loading indicator while more items are being loaded.

Props

The InfiniteScroll component accepts the following props:

  • fetchMore: A function to load more items.
  • hasMore: A boolean flag indicating whether there are more items to load.
  • children: The items to display in the scroll container.
  • loader: An optional loading indicator to display while more items are being loaded. Defaults to <p>Loading...</p>.
  • endMessage: An optional message to display when there are no more items to load. Defaults to <p>No more items to load.</p>.
  • threshold: An optional threshold value to trigger the fetchMore function before reaching the bottom of the scroll container. The default value is 0.8.
  • position: An optional position value to set the scroll container's position. The default value is bottom.
  • className: An optional class name to apply to the scroll container.
  • style: An optional style object to apply to the scroll container.

License

MIT