Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
LoadableLibrary.preload();
// Should allow force loading
LoadableLibrary.load().then(Component => {
;
});
}
// lazy.lib
{
// Should infer types from module with default export and reflect them in children render prop
const LazyDefaultLibrary = lazy.lib(defaultImportLibLoader);
{({ default: { getTestObj } }) => getTestObj().foo};
// Should infer types from module without default export and reflect them in children render prop
const LazyLibrary = lazy.lib(importLibLoader);
{({ getTestObj }) => getTestObj().foo};
// Should allow passing fallback prop
Loading library...}>{({ getTestObj }) => getTestObj().foo};
// Should reflect inferred types from module in ref
const ref = React.createRef();
;
ref.current!.getTestObj().foo;
// Should allow preloading
LazyDefaultLibrary.preload();
// Should allow force loading
LazyDefaultLibrary.load().then(Component => {
;
;
ref.current!.getTestObj().foo;
// Should allow preloading
LoadableLibrary.preload();
// Should allow force loading
LoadableLibrary.load().then(Component => {
;
});
}
// lazy.lib
{
// Should infer types from module with default export and reflect them in children render prop
const LazyDefaultLibrary = lazy.lib(defaultImportLibLoader);
{({ default: { getTestObj } }) => getTestObj().foo};
// Should infer types from module without default export and reflect them in children render prop
const LazyLibrary = lazy.lib(importLibLoader);
{({ getTestObj }) => getTestObj().foo};
// Should allow passing fallback prop
Loading library...}>{({ getTestObj }) => getTestObj().foo};
// Should reflect inferred types from module in ref
const ref = React.createRef();
;
ref.current!.getTestObj().foo;
// Should allow preloading
LazyDefaultLibrary.preload();
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)