Skip to content

fix(hooks): prevent infinite refetch loop in useApi for inline objects - #1243

Merged
RUKAYAT-CODER merged 3 commits into
rinafcode:mainfrom
Nacho1499:fix/useApi
Aug 26, 2026
Merged

fix(hooks): prevent infinite refetch loop in useApi for inline objects#1243
RUKAYAT-CODER merged 3 commits into
rinafcode:mainfrom
Nacho1499:fix/useApi

Conversation

@Nacho1499

Copy link
Copy Markdown
Contributor

Closes #895

PR Description:
Fixes an infinite fetch loop in the useApi hook caused by inline body and fetchOptions object literals changing identity on every render.
Introduced useRef combined with stringified serialization (JSON.stringify) for body and fetchOptions to ensure stable dependency tracking.
Prevented unnecessary recreation of fetchData and redundant re-firing of network requests when callers pass inline objects.
Cleaned up exhaustive dependency handling cleanly.

Type of Change
[x] Bug fix

Checklist
[x] Code follows project style guidelines
[x] Self-review completed
[x] No console errors

@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@Nacho1499 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER
RUKAYAT-CODER merged commit ed57086 into rinafcode:main Aug 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix useApi infinite refetch loop caused by inline body/options object

2 participants