forked from pancakeswap/pancake-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
109 lines (103 loc) · 3.41 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import React, { useEffect, lazy } from 'react'
import { Router, Redirect, Route, Switch } from 'react-router-dom'
import { ResetCSS } from '@pancakeswap-libs/uikit'
import BigNumber from 'bignumber.js'
import useEagerConnect from 'hooks/useEagerConnect'
import { useFetchPriceList, useFetchProfile, useFetchPublicData } from 'state/hooks'
import GlobalStyle from './style/Global'
import Menu from './components/Menu'
import SuspenseWithChunkError from './components/SuspenseWithChunkError'
import ToastListener from './components/ToastListener'
import PageLoader from './components/PageLoader'
import EasterEgg from './components/EasterEgg'
import Pools from './views/Pools'
import history from './routerHistory'
// Route-based code splitting
// Only pool is included in the main bundle because of it's the most visited page
const Home = lazy(() => import('./views/Home'))
const Farms = lazy(() => import('./views/Farms'))
const Lottery = lazy(() => import('./views/Lottery'))
const Ifos = lazy(() => import('./views/Ifos'))
const NotFound = lazy(() => import('./views/NotFound'))
const Collectibles = lazy(() => import('./views/Collectibles'))
const Teams = lazy(() => import('./views/Teams'))
const Team = lazy(() => import('./views/Teams/Team'))
const Profile = lazy(() => import('./views/Profile'))
const TradingCompetition = lazy(() => import('./views/TradingCompetition'))
const Predictions = lazy(() => import('./views/Predictions'))
// This config is required for number formating
BigNumber.config({
EXPONENTIAL_AT: 1000,
DECIMAL_PLACES: 80,
})
const App: React.FC = () => {
// Monkey patch warn() because of web3 flood
// To be removed when web3 1.3.5 is released
useEffect(() => {
console.warn = () => null
}, [])
useEagerConnect()
useFetchPublicData()
useFetchProfile()
useFetchPriceList()
return (
<Router history={history}>
<ResetCSS />
<GlobalStyle />
<Menu>
<SuspenseWithChunkError fallback={<PageLoader />}>
<Switch>
<Route path="/" exact>
<Home />
</Route>
<Route path="/farms">
<Farms />
</Route>
<Route path="/pools">
<Pools />
</Route>
<Route path="/lottery">
<Lottery />
</Route>
<Route path="/ifo">
<Ifos />
</Route>
<Route path="/collectibles">
<Collectibles />
</Route>
<Route exact path="/teams">
<Teams />
</Route>
<Route path="/teams/:id">
<Team />
</Route>
<Route path="/profile">
<Profile />
</Route>
<Route path="/competition">
<TradingCompetition />
</Route>
<Route path="/prediction">
<Predictions />
</Route>
{/* Redirect */}
<Route path="/staking">
<Redirect to="/pools" />
</Route>
<Route path="/syrup">
<Redirect to="/pools" />
</Route>
<Route path="/nft">
<Redirect to="/collectibles" />
</Route>
{/* 404 */}
<Route component={NotFound} />
</Switch>
</SuspenseWithChunkError>
</Menu>
<EasterEgg iterations={2} />
<ToastListener />
</Router>
)
}
export default React.memo(App)