react components lazy code example
Example 1: lazy react
import React, { Suspense } from 'react';
const OtherComponent = React.lazy(() => import('./OtherComponent'));
function MyComponent() {
return (
<div>
<Suspense fallback={<div>Loading...</div>}>
<OtherComponent />
</Suspense>
</div>
);
}
Example 2: lazy react
import("./math").then(math => {
console.log(math.add(16, 26));
});