Spaces:
Sleeping
Sleeping
Download server/templates/level_8/InfiniteScroll.js from anonajay/lint_coding_agent: direct link, hf CLI and curl.
- Browser
- Download file 696 Bytes
-
https://huggingface.co/spaces/anonajay/lint_coding_agent/resolve/main/server/templates/level_8/InfiniteScroll.js
- Command line
-
hf download hf://spaces/anonajay/lint_coding_agent/server/templates/level_8/InfiniteScroll.js
-
curl -L -o InfiniteScroll.js https://huggingface.co/spaces/anonajay/lint_coding_agent/resolve/main/server/templates/level_8/InfiniteScroll.js
696 Bytes
| import React, { useEffect, useRef } from 'react'; | |
| const InfiniteScroll = ({ loadMore }) => { | |
| const loaderRef = useRef(null); | |
| useEffect(() => { | |
| const observer = new IntersectionObserver((entries) => { | |
| if (entries[0].isIntersecting) { | |
| loadMore(); | |
| } | |
| }); | |
| if (loaderRef.current) { | |
| observer.observe(loaderRef.current); | |
| } | |
| // BROKEN: Missing cleanup function! | |
| // The observer will keep watching the DOM even if | |
| // this component is destroyed. | |
| }, [loadMore]); | |
| return <div ref={loaderRef}>Loading more posts...</div>; | |
| }; | |
| export default InfiniteScroll; |