forked from OperationCode/operationcode_frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
36 lines (31 loc) · 979 Bytes
/
App.js
File metadata and controls
36 lines (31 loc) · 979 Bytes
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
import React, { Component } from 'react';
import { Route, Router } from 'react-router';
import ReactGA from 'react-ga';
import createHistory from 'history/createBrowserHistory';
import ScrollToTop from 'shared/components/scrollToTop/scrollToTop';
import Home from './scenes/home/home';
const history = createHistory();
ReactGA.initialize('UA-75642413-1');
class App extends Component {
componentDidMount() {
if (process.env.NODE_ENV === 'production') {
// History listening doesn't catch first page load
ReactGA.set({ page: history.location.pathname });
ReactGA.pageview(history.location.pathname);
history.listen((location) => {
ReactGA.set({ page: location.pathname });
ReactGA.pageview(location.pathname);
});
}
}
render() {
return (
<Router history={history}>
<ScrollToTop>
<Route path="/" component={Home} />
</ScrollToTop>
</Router>
);
}
}
export default App;