Code splitting with React - suspense
React supports code splitting by default now using Suspense as shown in the following code snippet.
Awesome stuff
import React, {lazy, Suspense} from 'react';
const OtherComponent = lazy(() => import('./OtherComponent'));
function MyComponent() {
return (
<Suspense fallback={
Loading...</div>}>
<OtherComponent />
</Suspense>
);
}
Comments