-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgatsby-browser.js
32 lines (29 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
import React from "react";
import { Provider } from "react-redux";
import { JssProvider } from "react-jss";
import CssBaseline from "@material-ui/core/CssBaseline";
import createStore from "./src/state/store";
import { MuiThemeProvider } from "@material-ui/core/styles";
import getPageContext from "./src/getPageContext";
export const onInitialClientRender = function() {
const ssStyles = window.document.getElementById("server-side-jss");
ssStyles && ssStyles.parentNode.removeChild(ssStyles);
};
export const wrapRootElement = ({ element }) => {
const store = createStore();
const pageContext = getPageContext();
const ConnectRootElement = (
<Provider store={store}>
<JssProvider
registry={pageContext.sheetsRegistry}
generateClassName={pageContext.generateClassName}
>
<MuiThemeProvider theme={pageContext.theme} sheetsManager={pageContext.sheetsManager}>
<CssBaseline />
{React.cloneElement(element, { pageContext })}
</MuiThemeProvider>
</JssProvider>
</Provider>
);
return ConnectRootElement;
};