Skip to content
Discussion options

You must be logged in to vote

I think using AbortController is a good approach for handling this particular case, especially when working with native fetch().

However, I wouldn't consider it a complete solution for every duplicate request scenario.

React StrictMode intentionally runs an additional Effect setup and cleanup cycle in development to help identify missing cleanup logic. So disabling StrictMode just to avoid duplicate requests isn't really the right fix.

For larger applications, I'd prefer using TanStack Query because it provides request deduplication, caching, automatic retries, and better control over server state.

My recommendation:

  • Use AbortController for simple component-level requests.
  • Use TanStack Q…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by kdva-code
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug GitHub or a GitHub feature is not working as intended Code Security Build security into your GitHub workflow with features to keep your codebase secure Welcome 🎉 Used to greet and highlight first-time discussion participants. Welcome to the community! source:ui Discussions created via Community GitHub templates Code Quality Code Quality helps users improve code reliability, maintainability, and overall project health
2 participants