useSWR + Suspense leads to infinite rerenders #1109
Unanswered
DevAtHeart
asked this question in
Q&A
Replies: 1 comment 3 replies
-
I managed to reproduce it here: https://codesandbox.io/s/swr-suspense-bug-f5owj Just enter something into the input and check console. I think it has to do with the request returning the same result as the cache (previous result). You can use the commented line to fix the issue! I want to verify, I am not doing something wrong before opening an issue.. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I have a problem that some configuration of useSWR together with Suspense lead to infinite rerenders but some do not.
I use:
I wrap my components in:
It is used like:
MyWidget
looks like:It will never render data but keep showing the fallback. In the background, the http request is repeated forever.
With suspense false, everything works perfectly.
With suspense true, it starts randomly going into infinite render loops, maybe a race condition?
It doesn't happen for all widgets, for most it NEVER happens.
It also never happens on first render.
It happens in dev mode and production.
Beta Was this translation helpful? Give feedback.
All reactions