This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!entries[0].isIntersecting) { | |
return; | |
} | |
// Função responsável por carregar mais itens |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
const [isLoading, setIsLoading] = useState(false); | |
// Restante do código | |
useEffect(() => { | |
const observer = new IntersectionObserver( | |
(entries: IntersectionObserverEntry[]) => { | |
if (!entries[0].isIntersecting || isLoading) { | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
const observer = new IntersectionObserver( | |
(entries: IntersectionObserverEntry[]) => { | |
// Função responsável por carregar mais itens | |
}, | |
{ | |
root: null, | |
rootMargin: '0px', | |
threshold: 0 | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
const loadingElementRef = useRef<HTMLDivElement>(null); | |
// Restante do código | |
return ( | |
<main className="app"> | |
<div className="list"> | |
{data.map(item => ( | |
<div key={item.id} className="item">{`Item ${item.id + 1}`}</div> |