index.tsx 1.38 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'));
7
const Experiment = lazy(() => import('./components/managementExp/ExperimentManager'));
Deshui Yu's avatar
Deshui Yu committed
8
import './index.css';
9
import './static/style/loading.scss';
10
import * as serviceWorker from './serviceWorker';
Deshui Yu's avatar
Deshui Yu committed
11
12

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

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

// 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();