this post was submitted on 09 Jul 2023
1 points (100.0% liked)

React

907 readers
1 users here now

A community for discussing anything related to the React UI framework and it's ecosystem.

https://react.dev/

Wormhole

!pico8@programming.dev

Icon base by Skoll under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
 

I haven't had a need for suspense, I use react query without suspense just using the data, error, isLoading etc state directly. And I don't see Suspens as a simpler pattern necessarily. What does it get you that other patterns don't? I'm curious to know your use cases!

you are viewing a single comment's thread
view the rest of the comments
[–] Max_P@lemmy.max-p.me 1 points 1 year ago

IIRC it does more than just show a loading screen: it also suspends rendering of that entire part of the app until it's ready. So if you're loading many (nested) things, it delays the rendering of the whole page instead of causing multiple renders in a row that can end up feeling rather laggy to the user, especially on slower devices, and particularly when you have a page with a ton of dynamic content.

I think it can also deal with the loading of the components themselves, if the whole page and all its subcomponents aren't already available/bundled.

But like any React components, there's nothing preventing you from just making your own similar one for your specific use case. They're not magic, they use the same APIs as you do.

I've never used Suspense personally but I also haven't used React in a couple years.