updated SSR to create custom GA listener from siteConfig
This commit is contained in:
parent
ba01ce8e68
commit
8ef29f2d68
3 changed files with 27 additions and 23 deletions
24
index.js
24
index.js
File diff suppressed because one or more lines are too long
|
@ -20,19 +20,20 @@ module.exports = (req, res) => {
|
||||||
let context = {};
|
let context = {};
|
||||||
|
|
||||||
// customize the reducer by passing in intial state configs
|
// customize the reducer by passing in intial state configs
|
||||||
const CustomizedReducers = Reducers(siteConfig);
|
const MyReducers = Reducers(siteConfig);
|
||||||
const CustomizedApp = App(siteConfig);
|
const MyApp = App(siteConfig);
|
||||||
|
const MyGAListener = GAListener(siteConfig);
|
||||||
|
|
||||||
// create a new Redux store instance
|
// create a new Redux store instance
|
||||||
const store = createStore(CustomizedReducers);
|
const store = createStore(MyReducers);
|
||||||
|
|
||||||
// render component to a string
|
// render component to a string
|
||||||
const html = renderToString(
|
const html = renderToString(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<StaticRouter location={req.url} context={context}>
|
<StaticRouter location={req.url} context={context}>
|
||||||
<GAListener>
|
<MyGAListener>
|
||||||
<CustomizedApp />
|
<MyApp />
|
||||||
</GAListener>
|
</MyGAListener>
|
||||||
</StaticRouter>
|
</StaticRouter>
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,8 +18,9 @@ import Helmet from 'react-helmet';
|
||||||
|
|
||||||
// configure the reducers by passing initial state configs
|
// configure the reducers by passing initial state configs
|
||||||
const siteConfig = require('siteConfig.js');
|
const siteConfig = require('siteConfig.js');
|
||||||
const CustomizedReducers = Reducers(siteConfig);
|
const MyReducers = Reducers(siteConfig);
|
||||||
const CustomizedApp = App(siteConfig);
|
const MyApp = App(siteConfig);
|
||||||
|
const MyGAListener = GAListener(siteConfig);
|
||||||
|
|
||||||
const returnSagaWithParams = (saga, params) => {
|
const returnSagaWithParams = (saga, params) => {
|
||||||
return function * () {
|
return function * () {
|
||||||
|
@ -35,7 +36,7 @@ module.exports = (req, res) => {
|
||||||
const middleware = applyMiddleware(sagaMiddleware);
|
const middleware = applyMiddleware(sagaMiddleware);
|
||||||
|
|
||||||
// create a new Redux store instance
|
// create a new Redux store instance
|
||||||
const store = createStore(CustomizedReducers, middleware);
|
const store = createStore(MyReducers, middleware);
|
||||||
|
|
||||||
// create saga
|
// create saga
|
||||||
const action = Actions.onHandleShowPageUri(req.params);
|
const action = Actions.onHandleShowPageUri(req.params);
|
||||||
|
@ -50,9 +51,9 @@ module.exports = (req, res) => {
|
||||||
const html = renderToString(
|
const html = renderToString(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<StaticRouter location={req.url} context={context}>
|
<StaticRouter location={req.url} context={context}>
|
||||||
<GAListener>
|
<MyGAListener>
|
||||||
<CustomizedApp />
|
<MyApp />
|
||||||
</GAListener>
|
</MyGAListener>
|
||||||
</StaticRouter>
|
</StaticRouter>
|
||||||
</Provider>
|
</Provider>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue