finds.dev← search

// the find

jamiebuilds/react-loadable

★ 16,523 · JavaScript · MIT · updated Jul 2024

:hourglass_flowing_sand: A higher order component for loading components with promises.

react-loadable is a higher-order component that wraps dynamic `import()` calls to give you loading states, error states, timeouts, and SSR support for code-split React components. It was the de facto solution for component-level code splitting before React's own `Suspense` and `lazy` landed. Today it's a historical artifact kept alive by legacy codebases.

The SSR story is genuinely well thought out — the Babel plugin, Webpack plugin, `Loadable.Capture`, and `getBundles` pipeline for injecting the right script tags server-side was ahead of its time. The `pastDelay` and `timedOut` props on the loading component are a nice touch that most home-rolled solutions miss. The preload API (`LoadableComponent.preload()` on hover before click) is still a pattern worth knowing. Documentation is unusually thorough for a library of this age.

Abandoned. Last meaningful commit is years old, and React.lazy + Suspense cover 95% of what this did, with first-party support and no extra package. The SSR bundle-injection approach it pioneered is superseded by frameworks like Next.js handling all of this at the framework level. The Babel plugin breaks when you wrap `Loadable` in your own HOC, forcing you to manually add `modules` and `webpack` opts, which defeats the point. Anyone starting a project today should not reach for this.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →