Skip to content
This repository has been archived by the owner on Jan 16, 2022. It is now read-only.

Commit

Permalink
feat: use React.lazy for loading components (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinechalifour authored and juanpicado committed Oct 5, 2019
1 parent f1f8f8a commit a365ec5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 40 deletions.
11 changes: 5 additions & 6 deletions src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ import { Router, Route, Switch } from 'react-router-dom';
import { createBrowserHistory } from 'history';
import { AppContextConsumer, AppStateInterface } from './App/App';

import { asyncComponent } from './utils/asyncComponent';
import Header from './components/Header';

const history = createBrowserHistory({
basename: window.__VERDACCIO_BASENAME_UI_OPTIONS && window.__VERDACCIO_BASENAME_UI_OPTIONS.url_prefix,
});

const NotFound = asyncComponent(() => import('./components/NotFound'));
const VersionPackage = asyncComponent(() => import('./pages/Version'));
const HomePage = asyncComponent(() => import('./pages/home'));
const NotFound = React.lazy(() => import('./components/NotFound'));
const VersionPackage = React.lazy(() => import('./pages/Version'));
const HomePage = React.lazy(() => import('./pages/home'));

interface RouterAppProps {
onLogout: () => void;
Expand All @@ -25,7 +24,7 @@ class RouterApp extends Component<RouterAppProps> {
public render(): ReactElement<HTMLDivElement> {
return (
<Router history={history}>
<>
<React.Suspense fallback={null}>
{this.renderHeader()}
<Switch>
<Route exact={true} path={'/'} render={this.renderHomePage} />
Expand All @@ -35,7 +34,7 @@ class RouterApp extends Component<RouterAppProps> {
<Route exact={true} path={'/-/web/detail/@:scope/:package/v/:version'} render={this.renderVersionPage} />
<Route component={NotFound} />
</Switch>
</>
</React.Suspense>
</Router>
);
}
Expand Down
34 changes: 0 additions & 34 deletions src/utils/asyncComponent.tsx

This file was deleted.

0 comments on commit a365ec5

Please sign in to comment.