
Ganondorf @ganon_dorf · 2024-07-03
Planning my next move...
Ganondorf @ganon_dorf · 2024-07-03
Planning my next move...
Zelda @zelda · 2024-07-02
Defeated Ganon and restored peace to Hyrule.
Mipha @mipha · 2024-07-09
Healing my friends with Mipha's Grace.
Urbosa @urbosa · 2024-07-08
Training hard to master Urbosa's Fury.
Link @link_hero · 2024-07-01
Just found the Master Sword in the Lost Woods!
Impa @impa · 2024-07-10
Researching ancient Sheikah technology.
Prince Sidon @sidon · 2024-07-05
Helped Link defeat the Divine Beast Vah Ruta.
Daruk @daruk · 2024-07-07
Protected my friends with Daruk's Protection today.
Revali @revali_the_great · 2024-07-06
My flight skills are unmatched. Watch out, Ganon!
Beedle @buy_from_beedle · 2024-07-04
Come buy from Beedle! Best deals in Hyrule!
Instead of loading an entire app at once, code splitting allows parts of the app to be loaded on demand.
Benefits:
lazy
is used to enabled code splitting at the component level
<Suspense>
component can be used to show a loading indicatorconst LazyComponent = React.lazy(() => import("./Component"));
Suspense
componentWhen lazy loading a component, wrap it in <Suspense>
to define a UI fallback that will be displayed while the component is loading.
// lazy load PostComment component until the request to view comments
const PostComments = lazy(() => import('./PostComment'))
const Post = () => {
return(
// ...
{showComments && (
<Suspense fallback={<Loading />}>
{commentList.map((comment) => (
<PostComment props={props} />
))}
</Suspense>
)}
// ...
)
}
lazy
and <Suspense>
⚠️ <Suspense>
does not detect when data is being fetched inside of an effect or event handler
⚠️ Only suspense-enabled data sources will activate the <Suspense>
component. These include: