2018-04-06 14:51:52 +01:00
|
|
|
import React from 'react';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import { renderToString } from 'react-dom/server';
|
2018-03-26 13:01:24 +01:00
|
|
|
|
2018-04-18 11:15:32 +01:00
|
|
|
import headComponents from './src/head';
|
|
|
|
|
2018-04-06 14:51:52 +01:00
|
|
|
import { createStore } from './src/redux/store';
|
|
|
|
|
2018-09-12 02:14:13 +03:00
|
|
|
export const replaceRenderer = ({
|
2018-04-06 14:51:52 +01:00
|
|
|
bodyComponent,
|
|
|
|
replaceBodyHTMLString
|
|
|
|
}) => {
|
2018-09-12 15:58:08 +03:00
|
|
|
const store = createStore();
|
2018-04-06 14:51:52 +01:00
|
|
|
|
|
|
|
const ConnectedBody = () => (
|
|
|
|
<Provider store={store}>{bodyComponent}</Provider>
|
|
|
|
);
|
|
|
|
replaceBodyHTMLString(renderToString(<ConnectedBody />));
|
|
|
|
};
|
2018-04-09 00:11:35 +01:00
|
|
|
|
2018-09-12 02:14:13 +03:00
|
|
|
export const onRenderBody = ({ setHeadComponents, setPostBodyComponents }) => {
|
2018-04-18 11:15:32 +01:00
|
|
|
setHeadComponents([...headComponents]);
|
2018-04-09 00:11:35 +01:00
|
|
|
setPostBodyComponents([
|
|
|
|
<script
|
2018-09-12 11:42:59 +03:00
|
|
|
async={true}
|
2018-04-09 00:11:35 +01:00
|
|
|
key='chai-CDN'
|
|
|
|
src='https://cdnjs.cloudflare.com/ajax/libs/chai/4.1.2/chai.min.js'
|
2018-09-04 18:14:00 +01:00
|
|
|
/>,
|
|
|
|
<script
|
|
|
|
async={true}
|
|
|
|
src='https://www.googletagmanager.com/gtag/js?id=AW-795617839'
|
|
|
|
/>,
|
|
|
|
<script
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: `
|
|
|
|
window.dataLayer = window.dataLayer || [];
|
|
|
|
function gtag(){dataLayer.push(arguments);}
|
|
|
|
gtag('js', new Date());
|
|
|
|
gtag('config', 'AW-795617839');
|
|
|
|
`
|
|
|
|
}}
|
2018-04-09 00:11:35 +01:00
|
|
|
/>
|
|
|
|
]);
|
2018-04-18 11:15:32 +01:00
|
|
|
};
|