Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
{
// 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 => {
;
});
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>}>
{({ default: moment }) => moment().format('HH:mm')}
)
const root = document.createElement('div')
document.body.append(root)
render(, root)