Lazy Loading
Question
What does React.lazy do?
Hint
lazy must be used with <Suspense> for fallback.
Explanation
React.lazy(() => import("./Component")) enables dynamic import of a component, splitting it into a separate bundle chunk loaded on demand. This reduces the initial bundle size. lazy components must be wrapped in <Suspense fallback={<Loading />}> which shows the fallback while the chunk loads. Common use: route-level code splitting. Combined with React.lazy and Suspense, you can load entire pages only when navigated to. Error boundaries can catch chunk loading failures.
Related Resources
Related Lessons
- Lazy Loading
Learn lazy loading.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.