Skip to content
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

useSuspenseQuery - bug or expected? Queries waterfalling in React 18 #327

Closed
tombryden opened this issue Jul 1, 2024 · 3 comments
Closed

Comments

@tombryden
Copy link

tombryden commented Jul 1, 2024

Hi,

In Next.js, I am seeing that if I navigate directly to a page with 2x components that fetch data in one Suspense boundary, suspense works as I expect (in React 18) - the queries run in parallel via SSR streaming.

      <Suspense fallback={<div>Loading...</div>}>
        <FetchSomeData />
        <FetchMoreData />
      </Suspense>

However, the same code will waterfall if not using Next.js SSR streaming (e.g. having a toggle to render the suspense boundary, or navigating to a page via a <Link />)

I could be wrong but I thought Suspense was supposed to run in parallel, hence the uproar regarding React 19 potentially changing this?

For more info, TkDodo's blog post on React 19 and Suspense - https://tkdodo.eu/blog/react-19-and-suspense-a-drama-in-3-acts

@tombryden tombryden changed the title useSuspenseQuery - bug or expected? Queries waterfalling useSuspenseQuery - bug or expected? Queries waterfalling in React 18 Jul 1, 2024
@phryneas
Copy link
Member

phryneas commented Jul 1, 2024

React 19 potentially changing this?

There's nothing potential about it - that change shipped months ago into frameworks consuming experimental or canary builds of React like Next.js 😅

It will be rolled back for React 19, but right now this is the behaviour of React in Next.js (they are not really using React 18)

@tombryden
Copy link
Author

tombryden commented Jul 1, 2024

Oh wow, I'm behind the times - didn't realise Next.js had already shipped this. Cheers

Copy link

github-actions bot commented Jul 1, 2024

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.

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

No branches or pull requests

2 participants