ReactJsReact Lazy Loading and Suspense

Lazy loading lets you load components only when they are needed, improving performance. Suspense allows you to show a fallback UI while components are loading.

import React, { Suspense, lazy } from 'react';

const LazyComponent = lazy(() => import('./LazyComponent'));

function App() {
  return (
    <Suspense fallback={<div>Loading...</div>}>
      <LazyComponent />
    </Suspense>
  );
}

export default App;