forked from howtographql/howtographql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatsby-browser.js
59 lines (51 loc) · 1.32 KB
/
gatsby-browser.js
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
// import React from 'react'
// import {Provider} from 'react-redux'
// import createStore from './src/createStore'
//
// const store = createStore()
//
// exports.wrapRootComponent = function wrapRootComponent({Root}) {
// return function wrapRootComponentComponent(props) {
// return (
// <Provider store={store}>
// <Root />
// </Provider>
// )
// }
// }
//
//
//
//
//
//
//
//
import React from 'react'
import { BrowserRouter as Router } from 'react-router-dom'
import { Provider } from 'react-redux'
import Promise from 'promise-polyfill'
import createStore from './src/createStore'
exports.replaceRouterComponent = ({ history }) => {
const store = createStore()
if (typeof Raven !== 'undefined') {
Raven.config('https://[email protected]/190747').install()
}
// for our IE11 users
if (!window.Promise) {
window.Promise = Promise
}
const ConnectedRouterWrapper = ({ children }) => (
<Provider store={store}>
<Router history={history}>{children}</Router>
</Provider>
)
return ConnectedRouterWrapper
}
exports.onRouteUpdate = function({ location }) {
// Don't track while developing.
if (process.env.NODE_ENV === `production` && typeof ga === `function`) {
ga(`set`, `page`, (location || {}).pathname)
ga(`send`, `pageview`)
}
}