How to use multiple useSWR hooks in NextJS with Suspense?
Unanswered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
I have a NextJS project where I'm trying to use SWR to fetch data. My problem is when I use more than two useSWR-hooks in one component I get these hook errors:
Warning: React has detected a change in the order of Hooks called by ComponentExample. This will lead to bugs and errors if not fixed.
Uncaught Error: Update hook called on initial render. This is likely a bug in React. Please file an issue.
Here is a minimum reproduction code repository: https://github.com/LarsFlieger/swr-suspense-multiple
I also created a stackoverflow: https://stackoverflow.com/questions/77599359/how-to-use-multiple-useswr-hooks-in-nextjs-with-suspense
Warning: React has detected a change in the order of Hooks called by ComponentExample. This will lead to bugs and errors if not fixed.
Uncaught Error: Update hook called on initial render. This is likely a bug in React. Please file an issue.
Here is a minimum reproduction code repository: https://github.com/LarsFlieger/swr-suspense-multiple
I also created a stackoverflow: https://stackoverflow.com/questions/77599359/how-to-use-multiple-useswr-hooks-in-nextjs-with-suspense
6 Replies
to be fair they don't fully recommend using suspense with swr, but id think you should open a bug rep on the swr github as knowone really can help fixing it here
@riský to be fair they don't fully recommend using suspense with swr, but id think you should open a bug rep on the swr github as knowone really can help fixing it here
Asiatic LionOP
Thank you for that idea! I'm going to do this 🙂
Maybe someone can share his experience or also discovers this problem.
but i really wonder what they are doing that it can't do multiple ngl
Asiatic LionOP
Hahha yes me too..
Asiatic LionOP
Continuing the discussion here: https://github.com/vercel/swr/issues/2849