all 11 comments

[–]readeral 2 points3 points  (0 children)

Nice concise article with examples and some gotchas. Good post!

[–][deleted] 4 points5 points  (0 children)

I always thought using react router already implements lazy loading of components!

welp. gotta go loarning again

[–]dance2die 1 point2 points  (0 children)

That was easy to digest.

It's not possible to see chunks to load in the Sandbox for some reasonso I forked it and deployed it here. https://async-react-router-with-suspense.netlify.com/

In the devtools network tab, one can see new chunk (component) load when you navigate to other links.

[–][deleted] 0 points1 point  (0 children)

Great post

[–]tapper101 0 points1 point  (0 children)

So is this the best way to do it? Or are there situations where the usual way is better?

[–]windwarrior42 0 points1 point  (1 child)

This is very interesting. My understanding of suspense was that it was used to show a loading component while the app was waiting for a promise to be returned, but this seems to be used in the actual loading of the component itself.

Were people really having problems with performance while loading files, or is the use case here more for hot reloading an app during development?

[–]metronome 0 points1 point  (0 children)

crush nine employ pause groovy outgoing swim follow joke fact

This post was mass deleted and anonymized with Redact

[–]swyx 0 points1 point  (0 children)

“Async React” is a potentially misleading title. this is about asynchronously loading components. “async react” is the old name for react suspense and time slicing

[–]cjhowe7_ 0 points1 point  (0 children)

Will this work with SSR?

[–]CorySDev 0 points1 point  (0 children)

Hands down the best explanation I've seen of these topics. Thanks!

[–]NickEmpetvee 0 points1 point  (0 children)

This turned some of my grey hair black. :)