Package Exports
- preact-lazy
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (preact-lazy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
preact-lazy
Asynchronously load preact components with optional fallback content (simple alternative to suspense + lazy).
Installation
npm i preact-lazy
Usage
// ToBeLazyLoaded.js
import {h} from 'preact';
// export must be default
export default () => <h1>LAZY LOADED!!!</h1>;
// index.js
import {h, render} from 'preact';
import lazy from 'preact-lazy';
import {FallbackComponent} from './components';
const ToBeLazyLoaded = lazy(() => import('./ToBeLazyLoaded'), /*optional*/ FallbackComponent);
const App = () => (
<div>
<h1>hello</h1>
<ToBeLazyLoaded/>
</div>
);
render(<App/>, document.body)