1.1.7 • Published 2 days ago

observer-infinite-scroll v1.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 days ago

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

1.1.7

2 days ago

1.1.6

6 days ago

1.1.5

6 days ago

1.1.4

2 months ago

1.1.3

2 months ago

1.1.1

2 months ago

1.1.0

2 months ago

1.1.2

2 months ago

1.0.8

2 months ago

1.0.7

2 months ago

1.0.6

2 months ago

1.0.5

2 months ago

1.0.4

2 months ago

1.0.3

2 months ago

1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago