-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fetch
requests repeating infinitely & not resolving
#41852
Comments
I think you should use the cache api to prevent this, i've just wrapped the import { cache } from 'react';
export const fetchData = cache(() =>
fetch('https://cataas.com/api/cats', {
method: 'GET',
}).then((res) => res.json())
); The solution here : |
Using |
Since the RFC for the cache isn't out yet, i suppose we should not use Jack Herrington made a video about it and gave different methods to fix the issue : https://youtu.be/ytXM05PVcFU?t=327 |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:52 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8112
Binaries:
Node: 16.17.1
npm: 8.15.0
Yarn: N/A
pnpm: 7.14.0
Relevant packages:
next: 13.0.0
eslint-config-next: 13.0.0
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome
How are you deploying your application? (if relevant)
No response
Describe the Bug
When fetching data with the new
use
hook the request is repeated infinitely. This problem only occurs in client components.app/test/TestPage.tsx
app/test/page.tsx
Expected Behavior
The request should not get stuck in a loop
Link to reproduction
https://stackblitz.com/edit/nextjs-bf3f3v?file=app/test/TestPage.tsx
To Reproduce
app
directoryuse
hook with a fetch request inside client page componentThe text was updated successfully, but these errors were encountered: