Problem Statement
How do you implement lazy loading of components in React?
Explanation
Use React.lazy() to load components only when needed, wrapped inside a <Suspense> fallback. This helps reduce bundle size and speeds up initial load.
Code Solution
SolutionRead Only
const Contact = React.lazy(() => import('./Contact'));
<Suspense fallback={<p>Loading...</p>}><Contact /></Suspense>Practice Sets
This question appears in the following practice sets: