Skip to content

Commit

Permalink
POC of code-splitting with Suspense
Browse files Browse the repository at this point in the history
  • Loading branch information
julienben authored and Gretzky committed Feb 25, 2019
1 parent 3b5e522 commit b43b841
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
11 changes: 7 additions & 4 deletions app/containers/FeaturePage/Loadable.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/**
* Asynchronously loads the component for FeaturePage
*/
import loadable from 'loadable-components';

import React, { lazy, Suspense } from 'react';
import LoadingIndicator from 'components/LoadingIndicator';
const Component = lazy(() => import('./index'));

export default loadable(() => import('./index'), {
LoadingComponent: LoadingIndicator,
});
export default () => (
<Suspense fallback={<LoadingIndicator />}>
<Component />
</Suspense>
);
11 changes: 7 additions & 4 deletions app/containers/HomePage/Loadable.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/**
* Asynchronously loads the component for HomePage
*/
import loadable from 'loadable-components';

import React, { lazy, Suspense } from 'react';
import LoadingIndicator from 'components/LoadingIndicator';
const Component = lazy(() => import('./index'));

export default loadable(() => import('./index'), {
LoadingComponent: LoadingIndicator,
});
export default () => (
<Suspense fallback={<LoadingIndicator />}>
<Component />
</Suspense>
);
11 changes: 7 additions & 4 deletions app/containers/NotFoundPage/Loadable.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/**
* Asynchronously loads the component for NotFoundPage
*/
import loadable from 'loadable-components';

import React, { lazy, Suspense } from 'react';
import LoadingIndicator from 'components/LoadingIndicator';
const Component = lazy(() => import('./index'));

export default loadable(() => import('./index'), {
LoadingComponent: LoadingIndicator,
});
export default () => (
<Suspense fallback={<LoadingIndicator />}>
<Component />
</Suspense>
);
14 changes: 0 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"intl": "1.2.5",
"invariant": "2.2.4",
"ip": "1.1.5",
"loadable-components": "2.2.3",
"lodash": "4.17.11",
"minimist": "1.2.0",
"prop-types": "15.7.2",
Expand Down

0 comments on commit b43b841

Please sign in to comment.