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 = {};
|
||||
|
||||
// customize the reducer by passing in intial state configs
|
||||
const CustomizedReducers = Reducers(siteConfig);
|
||||
const CustomizedApp = App(siteConfig);
|
||||
const MyReducers = Reducers(siteConfig);
|
||||
const MyApp = App(siteConfig);
|
||||
const MyGAListener = GAListener(siteConfig);
|
||||
|
||||
// create a new Redux store instance
|
||||
const store = createStore(CustomizedReducers);
|
||||
const store = createStore(MyReducers);
|
||||
|
||||
// render component to a string
|
||||
const html = renderToString(
|
||||
<Provider store={store}>
|
||||
<StaticRouter location={req.url} context={context}>
|
||||
<GAListener>
|
||||
<CustomizedApp />
|
||||
</GAListener>
|
||||
<MyGAListener>
|
||||
<MyApp />
|
||||
</MyGAListener>
|
||||
</StaticRouter>
|
||||
</Provider>
|
||||
);
|
||||
|
|
|
@ -18,8 +18,9 @@ import Helmet from 'react-helmet';
|
|||
|
||||
// configure the reducers by passing initial state configs
|
||||
const siteConfig = require('siteConfig.js');
|
||||
const CustomizedReducers = Reducers(siteConfig);
|
||||
const CustomizedApp = App(siteConfig);
|
||||
const MyReducers = Reducers(siteConfig);
|
||||
const MyApp = App(siteConfig);
|
||||
const MyGAListener = GAListener(siteConfig);
|
||||
|
||||
const returnSagaWithParams = (saga, params) => {
|
||||
return function * () {
|
||||
|
@ -35,7 +36,7 @@ module.exports = (req, res) => {
|
|||
const middleware = applyMiddleware(sagaMiddleware);
|
||||
|
||||
// create a new Redux store instance
|
||||
const store = createStore(CustomizedReducers, middleware);
|
||||
const store = createStore(MyReducers, middleware);
|
||||
|
||||
// create saga
|
||||
const action = Actions.onHandleShowPageUri(req.params);
|
||||
|
@ -50,9 +51,9 @@ module.exports = (req, res) => {
|
|||
const html = renderToString(
|
||||
<Provider store={store}>
|
||||
<StaticRouter location={req.url} context={context}>
|
||||
<GAListener>
|
||||
<CustomizedApp />
|
||||
</GAListener>
|
||||
<MyGAListener>
|
||||
<MyApp />
|
||||
</MyGAListener>
|
||||
</StaticRouter>
|
||||
</Provider>
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue