Skip to content

BKJang/use-lazyload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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>
  )
}
cd example
npm install
npm run start

License

MIT © BKJang


This hook is created using create-react-hook.

About

📚This is custom hooks for lazy loading in react.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published