Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-loadable

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-loadable

A higher order component for loading components with promises

  • 5.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
268K
decreased by-7.71%
Maintainers
2
Weekly downloads
 
Created

What is react-loadable?

react-loadable is a higher-order component for loading components with dynamic imports. It helps in code-splitting and lazy loading of components, which can improve the performance of React applications by reducing the initial load time.

What are react-loadable's main functionalities?

Basic Usage

This feature allows you to dynamically import a component and display a loading indicator while the component is being loaded.

const LoadableComponent = Loadable({
  loader: () => import('./MyComponent'),
  loading: () => <div>Loading...</div>,
});

function App() {
  return (
    <div>
      <LoadableComponent />
    </div>
  );
}

Custom Loading Component

This feature allows you to use a custom loading component that can handle different states like loading and error.

const LoadableComponent = Loadable({
  loader: () => import('./MyComponent'),
  loading: ({ isLoading, error }) => {
    if (isLoading) {
      return <div>Loading...</div>;
    } else if (error) {
      return <div>Error loading component!</div>;
    } else {
      return null;
    }
  },
});

function App() {
  return (
    <div>
      <LoadableComponent />
    </div>
  );
}

Preloading Components

This feature allows you to preload a component before it is actually needed, which can help in reducing the load time when the component is eventually rendered.

const LoadableComponent = Loadable({
  loader: () => import('./MyComponent'),
  loading: () => <div>Loading...</div>,
});

LoadableComponent.preload();

function App() {
  return (
    <div>
      <LoadableComponent />
    </div>
  );
}

Other packages similar to react-loadable

FAQs

Package last updated on 09 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc