React Lazy & Suspense
React Lazy
In the large-scale project, there is lots of component, the size of chunk file will be large which increase the loading time and affect the user experience
By using react lazy, it divides a chunk file into several chunk files. Only when the component is used, the corresponding chunk file will be loaded, which will decrease the loading time as the size of chunk is decreased
The common use case is to put react lazy outside the router
From the above examples, we can see that a chunk file is divided into 2 files, the file only appear when the corresponding page is loaded
React Suspense
Only Suspense-enabled data sources will activate the Suspense component. They include:
Last updated
Was this helpful?