How to use the @loadable/component.lazy function in @loadable/component

To help you get started, we’ve selected a few @loadable/component examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / loadable__component / loadable__component-tests.tsx View on Github external
LoadableComponent.preload();

    // Should allow force loading
    LoadableComponent.load().then(Component => {
        ;
    });
}

// lazy
{
    // Should infer props from imported component with default export
    const LazyDefaultComponent = lazy(defaultImportComponentLoader);
    ;

    // Should infer props from imported component without default export
    const LazyComponent = lazy(importComponentLoader);
    ;

    // Should allow passing fallback prop
    loading...} />;

    // Should allow preloading
    LazyComponent.preload();

    // Should allow force loading
    LazyComponent.load().then(Component => {
        ;
    });
}

// loadable.lib
{
github DefinitelyTyped / DefinitelyTyped / types / loadable__component / loadable__component-tests.tsx View on Github external
// Should allow passing `fallback` prop to loadable component
    loading...} />;

    // Should allow preloading
    LoadableComponent.preload();

    // Should allow force loading
    LoadableComponent.load().then(Component => {
        ;
    });
}

// lazy
{
    // Should infer props from imported component with default export
    const LazyDefaultComponent = lazy(defaultImportComponentLoader);
    ;

    // Should infer props from imported component without default export
    const LazyComponent = lazy(importComponentLoader);
    ;

    // Should allow passing fallback prop
    loading...} />;

    // Should allow preloading
    LazyComponent.preload();

    // Should allow force loading
    LazyComponent.load().then(Component => {
        ;
    });
github gregberge / loadable-components / examples / suspense / src / index.js View on Github external
import React, { Suspense } from 'react'
import { render } from 'react-dom'
import { lazy } from '@loadable/component'

const Hello = lazy(() => import('./Hello'))
const Moment = lazy.lib(() => import('moment'))

const App = () => (
  <div>
    Loading...</div>}&gt;
      
      {({ default: moment }) =&gt; moment().format('HH:mm')}
    
  
)

const root = document.createElement('div')
document.body.append(root)

render(, root)

@loadable/component

React code splitting made easy.

MIT
Latest version published 7 months ago

Package Health Score

81 / 100
Full package analysis