All files / src App.jsx

0% Statements 0/13
0% Branches 0/4
0% Functions 0/3
0% Lines 0/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                                                                                                 
import React, { Suspense } from 'react';
import { hot } from 'react-hot-loader/root';
import sscache from 'session-storage-cache';
import {
  Router,
  Route,
  Switch,
} from 'react-router-dom';
import { createBrowserHistory as createHistory } from 'history';
import ReactGA from 'react-ga';
import ScrollProvider from './lib/ScrollContext';
import PerfProvider from './lib/PerfContext';
 
import 'normalize.css';
import './assets/styles/typeplate.scss';
import styles from './App.scss';
 
import Loader from './components/Loader';
import Navbar from './components/Navbar';
import CookieNotice from './components/CookieNotice';
 
const Dashboard = React.lazy(() => import('./containers/Dashboard'));
 
sscache.flush();
 
// Initialize history.
const history = createHistory();
ReactGA.initialize('UA-9138282-16');
ReactGA.set({ anonymizeIp: true });
 
history.listen((location) => {
  const cookiesAccepted = localStorage ? localStorage.getItem('cookiesAccepted') : false;
  if (!cookiesAccepted) {
    return;
  }
  ReactGA.set({ page: location.pathname });
  ReactGA.pageview(location.pathname);
});
 
function App() {
  return (
    <Router history={history}>
      <div className={styles.app}>
        <Switch>
          <Route>
            <PerfProvider>
              <ScrollProvider>
                <>
                  <Navbar />
                  <Suspense fallback={<Loader />}>
                    <Dashboard />
                  </Suspense>
                  <CookieNotice />
                </>
              </ScrollProvider>
            </PerfProvider>
          </Route>
        </Switch>
      </div>
    </Router>
  );
}
 
export default hot(App);