Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
React.lazy loads a component's code on first render as a separate chunk, and Suspense shows a fallback while it loads; place boundaries where a loading state makes sense, such as around a route or a heavy panel.
const Chart = lazy(() => import("./Chart")) tells the bundler to split Chart into its own chunk that downloads only when Chart first renders. While loading, the component suspends, and the nearest Suspense boundary above it shows its fallback. Boundary placement is a UX decision: a boundary per route avoids blanking the whole app, and smaller boundaries around heavy, below-the-fold widgets keep the rest interactive. Lazy components must be declared at module level, and loading failures should be handled by an error boundary. Preloading the import on hover or route intent can hide the delay.