use-lazyload
v1.0.0
Published
>
Downloads
4
Maintainers
Readme
use-lazyload
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.