a tiny lazyload library made by miracle_sumail, use IntersectionObserver API to accompanish this functionality
1. see the code inside, make use of react hooks
const LazyBox: React.FC<any> = { const ref: any = ; let visible setVisible = ; // let [io] = useObserver({visible, setVisible}); const io = return <div className=className ref=ref> visible ? children : null </div>}
just a total of 34 lines, so tiny...
2. how to use
{ return <> <LazyBox className='lazybox' threshold=2> <div>fwegwgwgg</div> </LazyBox> </> }