🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

@mikexrmn/use-infinite-scroll

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mikexrmn/use-infinite-scroll

A custom hook for infinite scrolling in React

1.0.1
latest
Source
npm
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
 
Created
Source

use-infinite-scroll

GitHub GitHub package.json version

A custom hook for implementing infinite scrolling in React applications.

Table of Contents

  • Installation
  • Usage
  • Examples
  • API Reference
  • Contributing
  • License

Installation

You can install use-infinite-scroll using npm or yarn:

npm install @mikexrmn/use-infinite-scroll

# OR

yarn add @mikexrmn/use-infinite-scroll

Usage

import React from "react";
import useInfiniteScroll from "@mikexrmn/use-infinite-scroll";

function MyComponent() {
  const fetchData = async (page) => {
    // Replace this with your data fetching logic
  };

  const { data, loading } = useInfiniteScroll(fetchData);

  return <div>{/_ Render your data and loading indicator here _/}</div>;
}

export default MyComponent;

API Reference

useInfiniteScroll(fetchDataFunction: (page: number) => Promise<any[]>): InfiniteScrollResult

Parameters

  • fetchDataFunction: A function that fetches data based on the current page number.

Returns

An object with the following properties:

  • data: An array of data items.
  • loading: A boolean indicating whether data is currently being loaded.

InfiniteScrollResult

An object with the following properties:

  • data: An array of data items.
  • loading: A boolean indicating whether data is currently being loaded.

Contributing

Contributions are welcome! Feel free to open issues and pull requests.

License

This project is licensed under the MIT License.

Keywords

react

FAQs

Package last updated on 02 Oct 2023

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