Next.js Discord

Discord Forum

Infinite scroll

Unanswered
Siamese posted this in #help-forum
Open in Discord
SiameseOP
Hi, could anyone take a look at my code to help me find the issue? There are no more stuff being loaded in and the first request always runs twice
https://sourceb.in/23ssGjCsFy

12 Replies

SiameseOP
I think the double request is just the fact im running in dev enviroment
SiameseOP
bump
Toyger
yeah first request running twice is because of strict, you should add abortcontroller to request and useffect
about infinite scroll are request at all running, or you getting some error?
SiameseOP
Thanks
For the scroll I will try to follow a YouTube guide
Maybe I will be able to get it to work
@Toyger https://medium.com/@icjoseph/using-react-to-understand-abort-controllers-eb10654485df
SiameseOP
In my case it's the exact same request being run twice, I got it in multiple places
I think it's just cus of dev env
yup
@Siamese I think it's just cus of dev env
Toyger
yes, it is because dev strict mode, and with abortcontroller your first request will be cancelled pretty fast, becase useEffect run twice, and 2 times run cleanup function. So it still will be shown in network inspector as cancelled but your api will get only single request now.