Fix an infinite scrolling list that fetches duplicates by adding a loading gate that blocks repeated triggers.
The scroll handler fires multiple times while fetching, causing duplicate data loads. Implement a flag that prevents a new fetch while one is already in progress.
Set a loading state when a fetch starts and only allow the next fetch after it completes. Also block triggers at the bottom of the list.
Make sure the fetch is triggered when the user scrolls near the bottom.
Test that scrolling loads new items once per trigger without duplicates.