Suspense is not resolved and the requests are looping
See original GitHub issueimport React, { Suspense } from 'react';
import useSWR from '@zeit/swr'
function StarWarsSuspense() {
return (
<Suspense fallback={<div>loading ...</div>}>
<StarWars />
</Suspense>
)
}
function StarWars() {
const { data } = useSWR('http://swquotesapi.digitaljedi.dk/api/SWQuote/RandomStarWarsQuote', fetch, { suspense: true });
return (
<div>
{data.starWarsQuote}
</div>
);
}
export default StarWarsSuspense;
With this code, i never get the final component, the placeholder stay forever, looking on chrome developer console, the requests are looping.
I made this code using the readme example, i tried change de fetch function to a random promise to see if i get out of fallback, without no results.
I doing something wrong or this is really something that should not happen ?

Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Suspense is not resolved and the requests are looping #46
I made this code using the readme example, i tried change de fetch function to a random promise to see if i get...
Read more >Suspense for Data Fetching (Experimental) - React
Suspense is not a data fetching library. It's a mechanism for data fetching libraries to communicate to React that the data a component...
Read more >React Suspense makes network waterfall when a component ...
I know that Suspense catches a Promise and shows Loading fallback until it is settled. So I understand why it make waterfall. Then,...
Read more >React Suspense: Lessons Learned While Loading Data
The asynchronous nature of data loading means each of these requests can be returned in any order.
Read more >useState with Suspense causes rerender loop? : r/reactjs
I have an issues though where useState keeps invoking the initial function passed into it, therefore rerendering the component. I have no idea ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@erikjung sorry that PR wasn’t included in
0.1.2
.Updating to
swr@0.1.5
will fix it:https://codesandbox.io/s/swr-playground-946db
I also get the same outcome: https://codesandbox.io/s/lucid-field-kbz20
Not sure if the
suspense
option is intended for the existing suspense feature in React stable or for the new concurrent functionality ofreact@experimental
. Tried both approaches with both versions of React and got the same results.Also unclear if anything special is required for the
fetch
function implementation. The docs imply that passing the globalfetch
function directly should work, but this basic example is wrapping fetch to resolve the.json()
promise as well. 🤷♂️