react-hot-component-loader

1.0.3 • Public • Published

Simple, but usable Async Component loader to be used with React-Hot-Loader.

The only one WORKING loader, specially designed for RHL workflow.

NPM

Usage

import hotLoader from 'react-hot-component-loader';
const Component = hotLoader( () => import('./Component'));

That is all. Component will be loaded and displayed. And not state will be lost on Hot Module Replacement.

Advanced Usage

import hotLoader from 'react-hot-component-loader';
const Component = hotLoader( 
  () => import('./Component'),
  {
    LoadingComponent: // the one to be shown upon loading
    ErrorComponent: // the one to be shown in case of error
    exportPicker: (value) => value.default // in case you need not default export
  }
);

Component API

Not HoC, but Component approach. Very usable for React-Hot-Loader, as long does not creates new or hidden components.

import { HotComponentLoader } from 'react-hot-component-loader';
const Component = (props) => (
  <HotComponentLoader
    loader = {() => import('./Component')}
    ...
  />
);

Read more about it on medium

Licence

MIT

Package Sidebar

Install

npm i react-hot-component-loader

Weekly Downloads

10

Version

1.0.3

License

MIT

Last publish

Collaborators

  • kashey