forked from greglobinski/gatsby-starter-personal-blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-browser.js
29 lines (23 loc) · 888 Bytes
/
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
import React from "react";
import { Router } from "react-router-dom";
import { Provider } from "react-redux";
import PropTypes from "prop-types";
import createStore from "./src/state/store";
// remove the JSS style tag generated on the server to avoid conflicts with the one added on the client
// exports.onInitialClientRender = function() {
// // eslint-disable-next-line no-undef
// var ssStyles = window.document.getElementById("server-side-jss");
// ssStyles && ssStyles.parentNode.removeChild(ssStyles);
// };
exports.replaceRouterComponent = ({ history }) => {
const store = createStore();
const ConnectedRouterWrapper = ({ children }) => (
<Provider store={store}>
<Router history={history}>{children}</Router>
</Provider>
);
ConnectedRouterWrapper.propTypes = {
children: PropTypes.object.isRequired
};
return ConnectedRouterWrapper;
};