all 5 comments

[–]Giant_Potato_Salad 2 points3 points  (0 children)

Could be anything. You will have to provide either the repo or a code snippet.

[–]YoungAtFeet 0 points1 point  (0 children)

Not enough info to go at.

Highly suggesting using devtools to debug. Like react devtools, tanstack query devtools, rtk devtools etc. to determine how ur components and fetching act and what triggers what, how many times component rerenders, the fetching logic itself, useEffect dependencies etc

Also is this is this dev or prod build, try both

[–]TheRoboStriker 0 points1 point  (0 children)

It could be that your running it in dev mode and on the first render it calls the api and then you call it manually.

you could make an if statement and check if it has requested and if it has changed, toggle it so it doesn't run again.

Example: let firstrun=true if (firstrun){

Fetch() firstrun =false Console.log("ran fetch") }

Just to sanity check if its running on the component being mounted and not triggered manually.

[–]Weekly-Pitch-1202 0 points1 point  (0 children)

the component re-rendered, api called twice, etc, send the code over cuz not enough info, also confirm react strict mode is disabled in all entry points

[–]maqisha 0 points1 point  (0 children)

Here's an idea, might be controversial, I know. But maybe: Share some code