index.tsx 1.27 KB
Newer Older
1
import React, { lazy, Suspense } from 'react';
2
import ReactDOM from 'react-dom';
Deshui Yu's avatar
Deshui Yu committed
3
import App from './App';
4
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
5
6
const Overview = lazy(() => import('./components/Overview'));
const TrialsDetail = lazy(() => import('./components/TrialsDetail'));
Deshui Yu's avatar
Deshui Yu committed
7
import './index.css';
8
import './static/style/loading.scss';
9
import * as serviceWorker from './serviceWorker';
Deshui Yu's avatar
Deshui Yu committed
10
11

ReactDOM.render(
12
    <Router>
13
14
        <App>
            <Switch>
15
16
17
18
19
20
21
                <Suspense
                    fallback={
                        <div className='loading'>
                            <img src={require('./static/img/loading.gif')} />
                        </div>
                    }
                >
22
                    <Route path='/' component={Overview} exact />
23
24
25
26
27
28
                    <Route path='/oview' component={Overview} />
                    <Route path='/detail' component={TrialsDetail} />
                </Suspense>
            </Switch>
        </App>
    </Router>,
29

30
    document.getElementById('root')
Deshui Yu's avatar
Deshui Yu committed
31
);
32
33
34
35
36

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();