0.0.3 • Published 4 years ago

preact-lazy v0.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

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)