forked from howtographql/howtographql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-browser.js
49 lines (43 loc) · 1.07 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
// 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 createStore from './src/createStore'
exports.replaceRouterComponent = ({ history }) => {
const store = createStore()
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`)
}
}