#Best practices with fetching on routes?

1 messages · Page 1 of 1 (latest)

harsh linden
#

Hey, everybody. I'm using RR7 on Framework/SPA mode. I noticed that when transitioning to a route, clientLoader will block rendering until it's been resolved. I have a /home route and a /products/:productId route. When navigating from one to the other, rendering will be blocked while the clientLoader for that route executes. Isn't that suboptimal? Is there a best practice for rendering the UI right away while the fetching happens?

My research has led me to solutions like using useEffect or some other sort of component-side fetching, but my understanding was that I could use clientLoader for that. If clientLoader is blocking and I can't even display some pending UI, what's the point? I don't see when I would actually want to block rendering without some user-friendly placeholder there.

TL;DR: clientLoader is blocking rendering. I don't think it's supposed to. How do you usually handle fetching + pending UI on your routes with SPA mode?

bitter plover
#

The route needs the data returned by the loader (client or server is the same) to render, so it’s blocking

#

You can return promises from a loader (again client or server is the same) then use Suspense to render a fallback while the promise resolves