mirror of
https://github.com/tjsga/tj-sga-website-react.git
synced 2025-04-21 12:00:17 -04:00
Added code-splitting with React.lazy
This commit is contained in:
parent
81e4d0ef99
commit
dd8e22d13f
26
src/App.tsx
26
src/App.tsx
|
@ -1,22 +1,23 @@
|
||||||
import React from 'react';
|
import React, { Suspense } from 'react';
|
||||||
import { BrowserRouter, Route, Switch } from 'react-router-dom';
|
import { BrowserRouter, Route, Switch } from 'react-router-dom';
|
||||||
import Layout from './components/Layout';
|
import Layout from './components/Layout';
|
||||||
|
|
||||||
import './App.css';
|
import './App.css';
|
||||||
|
|
||||||
import index from './pages/index';
|
const index = React.lazy(() => import('./pages/index'));
|
||||||
import initiatives from './pages/initiatives';
|
const initiatives = React.lazy(() => import('./pages/initiatives'));
|
||||||
import involved from './pages/involved';
|
const involved = React.lazy(() => import('./pages/involved'));
|
||||||
import mission from './pages/mission';
|
const mission = React.lazy(() => import('./pages/mission'));
|
||||||
import news from './pages/news';
|
const news = React.lazy(() => import('./pages/news'));
|
||||||
import newsarticle from './pages/newsarticle';
|
const newsarticle = React.lazy(() => import('./pages/newsarticle'));
|
||||||
import notFound from './pages/404';
|
const notfound = React.lazy(() => import('./pages/404'));
|
||||||
import officers from './pages/officers';
|
const officers = React.lazy(() => import('./pages/officers'));
|
||||||
import committee from './pages/committee';
|
const committee = React.lazy(() => import('./pages/committee'));
|
||||||
import classcouncil from './pages/classcouncil';
|
const classcouncil = React.lazy(() => import('./pages/classcouncil'));
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return (
|
return (
|
||||||
|
<Suspense fallback="Loading...">
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Layout>
|
<Layout>
|
||||||
<Switch>
|
<Switch>
|
||||||
|
@ -28,10 +29,11 @@ export default function App() {
|
||||||
<Route path='/officers' exact component={officers} />
|
<Route path='/officers' exact component={officers} />
|
||||||
<Route path='/committee' exact component={committee} />
|
<Route path='/committee' exact component={committee} />
|
||||||
<Route path='/class-council' exact component={classcouncil} />
|
<Route path='/class-council' exact component={classcouncil} />
|
||||||
<Route path='/:path' component={notFound} />
|
<Route path='/:path' component={notfound} />
|
||||||
<Route path='/' exact component={index} />
|
<Route path='/' exact component={index} />
|
||||||
</Switch>
|
</Switch>
|
||||||
</Layout>
|
</Layout>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
|
</Suspense>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user