10LOC

#error-boundary

Reactintermediate

React.lazy + Suspense with an error boundary fallback

import { lazy, Suspense, Component, type ReactNode } from "react";

// In a real app, SettingsPanelImpl would live in its own file and this
// would be lazy(() => import("./SettingsPanel")) instead -- this snippet
// is one self-contained file, so it wraps an inline component the same

Code-split a component with React.lazy and catch its load failures with an error boundary, so a flaky chunk load does not blank the page.