RevereCRE / relay-nextjs

⚡️ Relay integration for Next.js apps
https://reverecre.github.io/relay-nextjs/
MIT License
250 stars 30 forks source link

Granular Loading Indicator #13

Closed mjnaderi closed 2 years ago

mjnaderi commented 3 years ago

Hi,

Thanks for this great library.

I need more granular control for displaying loading state. I want to display a loading spinner in a child component, not the whole page.

I commented <Suspense> from component.tsx, but I get a weird error when navigating.

This is the error that was printed in my browser console for "example project":

image

And this is displayed in page:

image

The error says "above error", but there is no error printed above.

rrdelaney commented 3 years ago

This is a bit difficult to do with how Suspense works. This library loads a query along with the page and lets Relay suspend on client-side navigations. If only part of the page needs data and you don't want to block you can use useLazyLoadQuery or create a fallback that works like the rest of the page without that data.

rrdelaney commented 2 years ago

Closing as this is pretty much incompatible with how this library works. If you'd like to only show a loading spinner in part of the app you can use useLazyLoadQuery. It's not currently possible to say "render the app except for this part".