use-lazyload
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

use-lazyload

NPM

Install

npm install --save use-lazyload

Usage

import * as React from 'react';
 
import { useLazyload } from 'use-lazyload';
 
const options: IObserverOptions = {
  root: null,
  rootMargin: "0px",
  thresholds: [0.0],
};
 
const onIntersectCallback = async () => {
  //...fetch items
}
 
const Example = () => {
  const [element, setElement] = useLazyload(onIntersectCallback, options);
  return (
    <div>
      {...items.map(
        //...
      )}
      {
        <div ref={setElement}>{isLoading}</div>
      }
    </div>
  )
}

Example

cd example
npm install
npm run start

License

MIT © BKJang


This hook is created using create-react-hook.

Package Sidebar

Install

npm i use-lazyload

Weekly Downloads

15

Version

1.0.0

License

MIT

Unpacked Size

1.28 MB

Total Files

25

Last publish

Collaborators

  • jangbongki