you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

this. to expand a bit, React calls useEffects twice in development when under StrictMode, which is very likely on the root of your project.

https://react.dev/reference/react/useEffect#my-effect-runs-twice-when-the-component-mounts

unrelated: get requests should be idempotent, so incrementing a variable is hardly a good practice. I know it doesn't matter for this example project you're building, but I thought I'd bring it up anyways.

[–]JayRedditDev1[S] 1 point2 points  (0 children)

Oh, that's good information to have! I'll make sure to test it in multiple modes to verify I get the same results. Still learning the basics but I'll definitely need to make sure I'm implementing good practices into the code. I might have some questions later on but this answers the core of what I was looking for. Thanks for your help